repvec: Repeat vectors

View source: R/repvec.R

repvecR Documentation

Repeat vectors

Description

Create matrices by repeating vectors row-wise or column-wise a specified number of times.

Usage

repvec(x, n = 1, dim = NULL, nrow = NULL, ncol = NULL)

Arguments

x

Scalar or vector.

n

Integer specifying the number of times x is to be repeated.

dim

Integer specifying along which dimension x is to be repeated.

nrow

Integer specifying the number of row-wise repetitions of x.

ncol

Integer specifying the number of column-wise repetitions of x.

Examples

  repvec(1, 12)              # Column vector of ones.
  repvec(1, ncol = 12)       # Row vector of ones.
  repvec(1:10, 12, dim = 2)  # 10x12 matrix with 1:10 in each column.
  repvec(1:10, 12, dim = 1)  # 12x10 matrix with 1:10 in each row.
  repvec(1:10, ncol = 12)    # 10x12 matrix with 1:10 in each column.


TobieSurette/gulf.utils documentation built on Dec. 1, 2024, 6:01 a.m.