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:

     'FUN' must be a function (or the name of it) which expects at
     least two arguments and which operates elementwise.

     '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.

     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'.

_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]

