repvec: A function that replicates a whole vector.

Description Usage Arguments Value See Also Examples

Description

A simple wrapper for rep that takes a vector and creates a matrix by replicating it certain number of times either as rows or as columns.

Usage

1
repvec(vec, nrep, dim)

Arguments

vec

A vector of any mode except list.

nrep

A strictly positive scalar that determines how many times vec will be replicated and added as new rows or new columns, as indicated by dim argument.

dim

A scalar with value of either 1 or 2. Value 1 will copy vector vec as rows, while value 2 will copy it as columns.

Value

A matrix with length(vec) rows and nrep columns if dim==2 and vice versa if dim==1.

See Also

rep

Examples

1
2
3
4
5
6
7
8
vec <- c(1,2,3,4)
repvec(vec, 4, 2)

vec <- c("character", "vector")
repvec(vec, 3, 1)

vec <- c(TRUE, FALSE, FALSE)
repvec(vec, 3, 2)

hstojic/hfunk documentation built on May 17, 2019, 6:16 p.m.