Learn R Programming

rje (version 1.4)

patternRepeat: Complex repetitions

Description

Recreate patters for collapsed arrays

Usage

patternRepeat(x, which, n, careful = TRUE)

Arguments

x
A vector to be repeated
which
Which indices of the implicit array are given in x
n
Dimensions of implicit array.
careful
logical indicating whether to check vailidty of other arguments or work quickly (mainly for recursion)

Value

  • A vector of length prod(n) containing suitably repeated and ordered elements of x.

Details

This function allows for complex repeating patterns. Consider an array with dimensions n; then for each value of the dimensions in which (contained in x), this function returns the pattern of values in which for each entry in the larger array.

Hence the length of x must be equal to prod(n[which]).

See Also

rep

Examples

Run this code
patternRepeat(1:4, c(1,2), c(2,2,2))
c(array(1:4, c(2,2,2)))

patternRepeat(1:4, c(1,3), c(2,2,2))
patternRepeat(1:4, c(2,3), c(2,2,2))

Run the code above in your browser using DataLab