vec2mat: Vector to Matrix Conversion

View source: R/vec2mat.R

vec2matR Documentation

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)

Value

A matrix

Examples

x <- runif(5)
vec2mat(x)
vec2mat(x, horizontal=FALSE)

exams.forge documentation built on Sept. 11, 2024, 5:32 p.m.