triu: Extract Upper Triangular Matrix

View source: R/convenience.R

triuR Documentation

Extract Upper Triangular Matrix

Description

Extract the upper triangular part of a matrix.

Usage

triu(x, k = 0, diag = TRUE)

Arguments

x

A matrix.

k

The sub-diagonal at and below which the matrix is filled. k = 0 is the main diagonal, while k < 0 is below it, and k > 0 is above. The default is 0.

diag

Logical indicating whether to include the diagonal. Default is TRUE.

Examples

triu(ones(5, 5))
triu(ones(5, 5), diag = FALSE)

ramify documentation built on June 24, 2025, 9:07 a.m.