Return a Matrix with Lower Triangle as TRUE values in R Programming – lower.tri() Function
Last Updated :
16 Jun, 2020
lower.tri()
function in R Language is used to return a matrix of logical values with lower triangle as TRUE.
Syntax: lower.tri(x, diag)
Parameters:
x: Matrix object
diag: Boolean value to include diagonal
Example 1:
mat < - matrix(c( 1 : 9 ), 3 , 3 , byrow = T)
lower.tri(mat, diag = F)
|
Output:
[, 1] [, 2] [, 3]
[1, ] FALSE FALSE FALSE
[2, ] TRUE FALSE FALSE
[3, ] TRUE TRUE FALSE
Example 2:
mat < - matrix(c( 1 : 9 ), 3 , 3 , byrow = T)
lower.tri(mat, diag = T)
|
Output:
[, 1] [, 2] [, 3]
[1, ] TRUE FALSE FALSE
[2, ] TRUE TRUE FALSE
[3, ] TRUE TRUE TRUE
Share your thoughts in the comments
Please Login to comment...