An embedded and charset-unspecified text was scrubbed... Name: not available Url: https://stat.ethz.ch/pipermail/r-help/attachments/20040223/5aa03b6a/attachment.pl
quesion on diag of matrix
4 messages · li xian, Spencer Graves, Marc Schwartz +1 more
A <- array(1:4, dim=c(2,2))
> sum(diag(A))
[1] 5
Is that what you want?
spencer graves
li xian wrote:
How to get the sum of the diag of matrix? Thanks! --------------------------------- [[alternative HTML version deleted]]
______________________________________________ R-help at stat.math.ethz.ch mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
On Mon, 2004-02-23 at 18:53, li xian wrote:
How to get the sum of the diag of matrix? Thanks!
If 'm' is your matrix: sum(diag(m)) See ?sum and ?diag, the latter of which will extract the diagonal of the matrix. Be sure to read the help for diag() fully for some of the usage caveats. HTH, Marc Schwartz
sum(diag(X))
On Mon, 23 Feb 2004, li xian wrote:
How to get the sum of the diag of matrix? Thanks! --------------------------------- [[alternative HTML version deleted]]
______________________________________________ R-help at stat.math.ethz.ch mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html