Similarly to upper.tri and lower.tri, returns a matrix of logicals to identify the diagonal of a square matrix
diagonal(M, output = c("matrix.logical", "vector.values"))
| M | matrix or other R object with |
|---|---|
| output | choose to either return a matrix of logical values ( |
square logical matrix with diagonal of TRUEs
#> [,1] [,2] [,3] [,4] #> [1,] TRUE FALSE FALSE FALSE #> [2,] FALSE TRUE FALSE FALSE #> [3,] FALSE FALSE TRUE FALSE #> [4,] FALSE FALSE FALSE TRUE