vec2mat: Vector to Matrix Conversion
Description
Converts a vector to a horizontal or vertical matrix and sets row-
or colnames
.
If rownames
or colnames
are given, then existing row names or column names are overwritten.
Usage
vec2mat(x, colnames = NULL, rownames = NULL, horizontal = TRUE)to_mat(x, colnames = NULL, rownames = NULL, horizontal = TRUE)
Arguments
- x
vector
- colnames
character: vector of new column names (default: NULL
)
- rownames
character: vector of new row names (default: NULL
)
- horizontal
logical: horizontal or vertical matrix (default: TRUE
)
Examples
Run this codex <- runif(5)
vec2mat(x)
vec2mat(x, horizontal=FALSE)
Run the code above in your browser using DataLab