Similarly to upper.tri and lower.tri, returns a matrix of logicals to identify the diagonal of a square matrix

non.diagonal(M, output = c("matrix.logical", "vector.values"))

Arguments

M

square matrix.

output

choose to either return a matrix of logical values (TRUEs, FALSEs on the diagonal, i.e. comparable behavior than upper.tri for instance) or a vector of the subsetted values of the matrix.

Value

either return a matrix of logical values (TRUEs, FALSEs on the diagonal) or a vector of the subsetted values of the matrix.

Examples

M<- matrix(sample(1:10,16,replace = TRUE),4,4) non.diagonal(M)
#> [,1] [,2] [,3] [,4] #> [1,] FALSE TRUE TRUE TRUE #> [2,] TRUE FALSE TRUE TRUE #> [3,] TRUE TRUE FALSE TRUE #> [4,] TRUE TRUE TRUE FALSE