rep_dim: Replicate Array Dimensions

View source: R/rep_dim.R

rep_dimR Documentation

Replicate Array Dimensions

Description

The rep_dim() function replicates array dimensions until the specified dimension sizes are reached, and returns the array.

The various broadcasting functions recycle array dimensions virtually, meaning little to no additional memory is needed.
The rep_dim() function, however, physically replicates the dimensions of an array (and thus actually occupies additional memory space).

Usage

rep_dim(x, tdim)

Arguments

x

an atomic or recursive array or matrix.

tdim

an integer vector, giving the target dimension to reach.

Value

Returns the replicated array.

Examples


x <- matrix(1:9, 3,3)
colnames(x) <- LETTERS[1:3]
rownames(x) <- letters[1:3]
names(x) <- month.abb[1:9]
print(x)

rep_dim(x, c(3,3,2)) # replicate to larger size

broadcast documentation built on Sept. 15, 2025, 5:08 p.m.

Related to rep_dim in broadcast...