seq2mat: Transforms a vector to a symmetric matrix

Description Usage Arguments Details Value Author(s) See Also Examples

View source: R/auxiliar.R

Description

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

Usage

1
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<c3><ad>s Revilla

See Also

upper.tri and lower.tri

Examples

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

Example output

If you use BioCor in published research, please cite:
  A B C  D  E
A 1 1 2  4  7
B 1 1 3  5  8
C 2 3 1  6  9
D 4 5 6  1 10
E 7 8 9 10  1
    A   B   C   D   E
A 1.0 0.1 0.2 0.4 0.7
B 0.1 1.0 0.3 0.5 0.8
C 0.2 0.3 1.0 0.6 0.9
D 0.4 0.5 0.6 1.0 1.0
E 0.7 0.8 0.9 1.0 1.0

BioCor documentation built on Nov. 8, 2020, 4:56 p.m.