RDocumentation
Moon
Learn R
Search all packages and functions
lasso2 (version 1.2-10)
tr: Trace of a Matrix
Description
Calculates the trace of a matrix
Usage
tr(mat)
Arguments
Value
The trace of the matrix, i.e. the sum of its diagonal elements, is returned.
Examples
Run this code
tr(cbind(
1
,
1
:
3
,
4
:
2
))
# 5
Run the code above in your browser using
DataLab