vec2mat | R Documentation |
Function to convert a vector into a square matrix by filling up the lower triangular part of the matrix.
vec2mat(x, diag=FALSE, corr=!diag, dimnames)
x |
a vector of the correct length. |
diag |
logical to specify whether the vector also contains the diagonal values of the lower triangular part of the matrix (the default is |
corr |
logical to specify whether the diagonal of the matrix should be replaced with 1's (the default is to do this when |
dimnames |
optional vector of the correct length with the dimension names of the matrix. |
The values in x
are filled into the lower triangular part of a square matrix with the appropriate dimensions (which are determined based on the length of x
). If diag=TRUE
, then x
is assumed to also contain the diagonal values of the lower triangular part of the matrix. If corr=TRUE
, then the diagonal of the matrix is replaced with 1's.
A matrix.
Wolfgang Viechtbauer wvb@metafor-project.org https://www.metafor-project.org
vec2mat(1:6, corr=FALSE)
vec2mat(seq(0.2, 0.7, by=0.1), corr=TRUE)
vec2mat(1:10, diag=TRUE)
vec2mat(1:6, corr=FALSE, dimnames=c("A","B","C","D"))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.