arep: Replicate array elements

arepR Documentation

Replicate array elements

Description

arep_times() and arep_each() are multidimensional versions of base::rep( , times=) and base::rep( , each=), respectively.

They're both generic functions with default methods that work on any array-like object that supports [ (single-bracket subsetting).

Usage

arep_times(x, times)
arep_each(x, each)

Arguments

x

An array-like object, that is, an ordinary array or any object with dimensions.

times, each

An integer vector parallel to dim(x) i.e. with one element per dimension in x.

Value

An array-like object of the same class as x and with dimensions dim(x) * times for arep_times or dim(x) * each for arep_each. The dimnames on x are propagated, if any.

See Also

  • base::rep in the base package.

  • array and matrix objects in base R.

Examples

m <- matrix(1:10, nrow=2)
arep_times(m, c(4, 2))
arep_each(m, c(4, 2))

## Note that the output array is 'prod(times)' (or 'prod(each)') times
## bigger than the input array!

Bioconductor/S4Arrays documentation built on Feb. 8, 2025, 10:13 a.m.