> 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]]
______________________________________________
[EMAIL PROTECTED] 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
______________________________________________ [EMAIL PROTECTED] 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