Learn R Programming

MCMCglmm (version 1.06)

Tri2M: Lower/Upper Triangle Elements of a Matrix

Description

Lower/Upper triangle elements of a matrix or forms a matrix from a vector of lower/upper triangle elements

Usage

Tri2M(x, lower.tri = TRUE, reverse = TRUE)

Arguments

x
Matrix or vector
lower.tri
If x is a matrix then the lower triangle (TRUE) or upper triangle FALSE elements (including diagonal elements) are returned. If x is a vector a matrix is formed under the assumption that x
reverse
logical: ifTRUE a symmetric matrix is formed, if FALSE the remaining triangle is left as zeros.

Value

  • numeric or matrix

Examples

Run this code
M<-rIW(10, diag(3))
x<-Tri2M(M)
x
Tri2M(x, reverse=TRUE)
Tri2M(x, reverse=FALSE)

Run the code above in your browser using DataLab