vec2symmat: Creates a Symmetric Matrix from a Vector

Description Usage Arguments Value Author(s) References Examples

View source: R/vec2symmat.R

Description

Takes a vector and, if the vector is of the correct lenght to be made into a symmetric matrix, performs the conversion.

Usage

1
vec2symmat(invec, diag = 1, byrow = TRUE)

Arguments

invec

The input vector

diag

The value for the diagonal

byrow

Logical. Whether the upper-triangle should be filled in by row

Value

A matrix

Author(s)

Ananda Mahto

References

http://stackoverflow.com/a/18598933/1270695

Examples

1
2
3
4
5
myvec <- c(-.55, -.48, .66, .47, -.38, -.46)
vec2symmat(myvec)

vec2symmat(1:15, diag = 0)
vec2symmat(1:15, diag = 0, byrow = FALSE)

mrdwab/SOfun documentation built on June 20, 2020, 6:15 p.m.