seq2mat: Transforms a vector to a symmetric matrix

View source: R/auxiliar.R

seq2matR Documentation

Transforms a vector to a symmetric matrix

Description

Fills a matrix of ncol = length(x) and nrow = length(x) with the values in dat and setting the diagonal to 1.

Usage

seq2mat(x, dat)

Arguments

x

names of columns and rows, used to define the size of the matrix

dat

Data to fill with the matrix with except the diagonal.

Details

dat should be at least choose(length(x), 2) of length. It assumes that the data provided comes from using the row and column id to obtain it.

Value

A square matrix with the diagonal set to 1 and dat on the upper and lower triangle with the columns ids and row ids from x.

Author(s)

LluĂ­s Revilla

See Also

upper.tri() and lower.tri()

Examples

seq2mat(LETTERS[1:5], 1:10)
seq2mat(LETTERS[1:5], seq(from = 0.1, to = 1, by = 0.1))

llrs/BioCor documentation built on March 9, 2024, 7:49 a.m.