outer(X, Y, FUN="*", ...) X %o% Y #operator form
FUN
.
Missing values (
NA
s) are allowed if
FUN
accepts them.
FUN
, if needed. The names of the arguments, if any,
should be those meaningful to
FUN
.
X
and
Y
, and such
that
FUN(X[i,j,k,...], Y[a,b,c,...])
is the
value of the
[i,j,k,...,a,b,c,...]
element.
(Vectors are considered to be one-dimensional arrays.)
outer
forms two arrays corresponding
to the data in
X
and
Y
,
each of which has a
dim
attribute formed by concatenating the
dim
attributes of
X
and
Y
.
It then calls
FUN
just once with these two arrays as arguments.
Therefore,
FUN
should be a function that operates elementwise
on vectors or arrays and expects (at least) two arguments.
z <- x %o% y # The outer product array # dim(z) == c(dim(as.array(x)), dim(as.array(y))) # simulate a two-way table outer(c(3.1, 4.5, 2.8, 5.2), c(2.7, 3.1, 2.8),"+") + matrix(rnorm(12), nrow=4) outer(month.name, 2001:2003, paste) # All month year combinations