Learn R Programming

callsync (version 0.2.3)

o.to.m: o.to.m

Description

Transforms a vector into a matrix where it assumes that the vector values are the lower triangular of the matrix: `m[lower.tri(m)] = o`. It includes 0 on the diagonal.

Usage

o.to.m(o, n = seq(sqrt(length(o) + 1) + 1))

Value

Returns a matrix where it assumes that `m[lower.tri(m)] = o`.

Arguments

o

the vector containing the values for the lower triangular (required)

n

the names for the rows and columns of the matrix (optional)

Examples

Run this code
m = matrix(1:9, nrow = 3, ncol = 3)
o = m[lower.tri(m)]
m_new = o.to.m(o)

Run the code above in your browser using DataLab