powered by
Calculates the trace of a square numeric matrix, i.e., the sum of its diagonal elements
tr(X)
a numeric value, the sum of diag(X)
diag(X)
a numeric matrix
X <- matrix(1:9, 3, 3) tr(X)
Run the code above in your browser using DataLab