Learn R Programming

PRIST (version 0.925)

applyFlat: Apply a vectorized binary operation recycling over last dimension

Description

When x is an array of order K, and y is an array of order K-1, whose dimensions otherwise agree, apply FUN by recycling y as necessary over dimension K of x.

Usage

applyFlat(x, y, FUN = "-")

Arguments

x

array, order K

y

array, order K-1

FUN

vectorized binary operation

Value

array, order K equal to FUN(x,y)

Examples

Run this code
# NOT RUN {
##Dumb example, could be done with scale(...,scale=FALSE)
# }
# NOT RUN {
x0 = matrix(1:10, ncol=2)
y0 = colMeans(x0)
dim(y0) = c(2,1)
x1 = applyFlat(x0,y0)
stopifnot(colMeans(x1)==0)
# }

Run the code above in your browser using DataLab