apply2arrays: Returns a vector or array or list of values obtained by...

Description Usage Arguments Value Examples

Description

Returns a vector or array or list of values obtained by applying a function to margins of two arrays or matrices.

Usage

1
apply2arrays(X, Y, XMARGIN, YMARGIN, FUN, ...)

Arguments

X,Y

arrays (each potentially a matrix)

XMARGIN,YMARGIN

vectors giving the subscripts which the function will be applied over. see apply for more information. for the special case here, note that all(dim(X)[XMARGIN] == dim(Y)[YMARGIN]) must be TRUE.

FUN

the function to be applied.

...

more arguments to FUN.

Value

a new array, or list if simplify2array cannot do it's job.

Examples

1
2
3
4
5
dims <- c(4, 2, 3, 1, 2)
set.seed(1)
(A <- array(rnorm(prod(dims[-2])), dims[-2]))
(B <- array(rnorm(prod(dims[-(3:4)])), dims[-(3:4)]))
apply2arrays(A, B, c(1, 4), c(1, 3), `%*%`)

stevencarlislewalker/ecoBayesIRT documentation built on May 30, 2019, 4:42 p.m.