vec2m: Stack a vector to form a matrix with repeating rows, with...

View source: R/functions.R

vec2mR Documentation

Stack a vector to form a matrix with repeating rows, with optional column names and transformation

Description

Stack a vector to form a matrix with repeating rows, with optional column names and transformation

Usage

vec2m(vv, nr = 1, trans = identity)

Arguments

vv

A vector which will become the row of a matrix

nr

Number of (identical) rows this matrix will contain

trans

An optional function that can take a matrix as its sole argument. Useful functions include 'as.data.frame()' 'as_tibble()' and 'as.table()'

Value

A matrix, unless the function specified in the 'trans' argument causes the output to be something else.

Examples

vec2m(1:10,5);
vec2m(1:10,5,tr=data.frame);
vec2m(setNames(1:12,month.name),3);

bokov/tidbits documentation built on Jan. 26, 2024, 6:25 p.m.