powered by
Extract the upper triangular part of a matrix.
triu(x, k = 0, diag = TRUE)
A matrix.
Diagonal below which to zero elements. k = 0 (the default) is the main diagonal, k < 0 is below it and k > 0 is above.
k = 0
Logical indicating whether to include the diagonal. Default is TRUE.
TRUE
triu(ones(5, 5)) triu(ones(5, 5), diag = FALSE)
Run the code above in your browser using DataLab