outer                  package:base                  R Documentation

_O_u_t_e_r _P_r_o_d_u_c_t _o_f _A_r_r_a_y_s

_D_e_s_c_r_i_p_t_i_o_n:

     The outer product of the arrays 'X' and 'Y' is the array 'A' with
     dimension 'c(dim(X), dim(Y))' where element 'A[c(arrayindex.x,
     arrayindex.y)] = FUN(X[arrayindex.x], Y[arrayindex.y], ...)'.

_U_s_a_g_e:

     outer(X, Y, FUN="*", ...)
     X %o% Y

_A_r_g_u_m_e_n_t_s:

    X, Y: First and second arguments for function 'FUN'. Typically a
          vector or array.

     FUN: a function to use on the outer products, found _via_
          'match.fun' (except for the special case '"*"').

     ...: optional arguments to be passed to 'FUN'.

_D_e_t_a_i_l_s:

     'X' and 'Y' must be suitable arguments for 'FUN'.  Each will be
     extended by 'rep' to length the products of the lengths of 'X' and
     'Y' before 'FUN' is called.

     'FUN' is called with these two extended vectors as arguments.
     Therefore, it must be a vectorized function (or the name of one),
     expecting at least two arguments.

     Where they exist, the [dim]names of 'X' and 'Y' will be copied to
     the answer, and a dimension assigned which is the concatenation of
     the dimensions of 'X' and 'Y' (or lengths if dimensions do not
     exist).

     'FUN = "*"' is handled internally as a special case, _via_
     'as.vector(X) %*% t(as.vector(Y))', and is intended only for
     numeric vectors and arrays.

     '%o%' is binary operator providing a wrapper for 'outer(x, y,
     "*")'.

_A_u_t_h_o_r(_s):

     Jonathan Rougier

_R_e_f_e_r_e_n_c_e_s:

     Becker, R. A., Chambers, J. M. and Wilks, A. R. (1988) _The New S
     Language_. Wadsworth & Brooks/Cole.

_S_e_e _A_l_s_o:

     '%*%' for usual (_inner_) matrix vector multiplication;
     'kronecker' which is based on 'outer'; 'Vectorize' for vectorizing
     a non-vectorized function.

_E_x_a_m_p_l_e_s:

     x <- 1:9; names(x) <- x
     # Multiplication & Power Tables
     x %o% x
     y <- 2:8; names(y) <- paste(y,":",sep="")
     outer(y, x, "^")

     outer(month.abb, 1999:2003, FUN = "paste")

     ## three way multiplication table:
     x %o% x %o% y[1:3]

