Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

vec2symMat

Convert a Vector into a Symmetric Matrix


Description

It converts a vector into a symmetric matrix by filling up the elements into the lower triangle of the matrix.

Usage

vec2symMat(x, diag = TRUE, byrow = FALSE)

Arguments

x

A vector of numerics or characters

diag

Logical. If it is TRUE (the default), the diagonals of the created matrix are replaced by elements of x; otherwise, the diagonals of the created matrix are replaced by "1".

byrow

Logical. If it is FALSE (the default), the created matrix is filled by columns; otherwise, the matrix is filled by rows.

Value

A symmetric square matrix based on column major

Author(s)

Mike W.-L. Cheung <mikewlcheung@nus.edu.sg>

See Also

Examples

vec2symMat(1:6)
#      [,1] [,2] [,3]
# [1,]    1    2    3
# [2,]    2    4    5
# [3,]    3    5    6

vec2symMat(1:6, diag=FALSE)
#      [,1] [,2] [,3] [,4]
# [1,]    1    1    2    3
# [2,]    1    1    4    5
# [3,]    2    4    1    6
# [4,]    3    5    6    1

vec2symMat(letters[1:6])
#      [,1] [,2] [,3]
# [1,] "a"  "b"  "c" 
# [2,] "b"  "d"  "e" 
# [3,] "c"  "e"  "f"

metaSEM

Meta-Analysis using Structural Equation Modeling

v1.2.5
GPL (>= 2)
Authors
Mike Cheung [aut, cre] (<https://orcid.org/0000-0003-0113-0758>)
Initial release
2020-11-29

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.