lower_tri: Return a triangular matrix

Description Usage Arguments Details Value See Also Examples

View source: R/lower_tri.R

Description

Returns the upper or lower triangle of a matrix.

Usage

1
2
3
4
5
6
7
lower_tri(x, diag = FALSE, valuesOnly = FALSE, otherVal = 0)

lowerTri(x, diag = FALSE, valuesOnly = FALSE, otherVal = 0)

upper_tri(x, diag = FALSE, valuesOnly = FALSE, otherVal = 0)

upperTri(x, diag = FALSE, valuesOnly = FALSE, otherVal = 0)

Arguments

x

A matrix

diag

logical. Include the diagonal? Default is false.

valuesOnly

logical. Return only the lower/upper triangle values (including diag argument)

otherVal

numeric or NA. what to make nonlower/upper values. 0 by default.

Details

This function returns the lower/upper triangle of a square matrix rather than just its indices (e.g. as lower.tri does). otherVal is only relevant if valuesOnly is FALSE.

Value

A lower or upper triangular matrix, possibly with diagonal. If valuesOnly is TRUE, then only the vector of values are returned.

See Also

lower.tri, diag, matrix

Examples

1
2
3
4
5
6
7
library(lazerhawk)
(m <- matrix(1:9, 3, 3, byrow=TRUE))
lower.tri(m)
lower_tri(m)
lower_tri(m, diag=TRUE, otherVal=NA)
lower_tri(m, valuesOnly=TRUE)
upper_tri(m, diag=TRUE, otherVal=NA)

mclark--/lazerhawk documentation built on July 17, 2018, 3:11 a.m.