lower.tri
Logical Matrix of the Lower or Upper Triangle

Description

Return a matrix of logical values the same size as the input matrix specified in the x argument. The lower or upper triangle contain TRUE; all other values contain FALSE.

Usage

lower.tri(x, diag = FALSE)
upper.tri(x, diag = FALSE)

Arguments

x a matrix.
diag a logical value. If TRUE, the diagonal elements are included in the triangle.
Value
returns a matrix of the same dimension as x. In the case of a lower triangle, the elements above the diagonal return FALSE and the elements below the diagonal return TRUE. The value of the diagonal elements depends on what you specify for the diag argument.
See Also
col, diag.
Examples
lower.tri(Sdatasets::freeny.x) 
upper.tri(Sdatasets::freeny.x, T) 

# A correlation matrix with 0.5 on all off-diagonals: corr <- diag(5) corr[lower.tri(corr)] <- 0.5 corr[upper.tri(corr)] <- 0.5 corr

Package base version 6.0.0-69
Package Index