EVOLUTION-MANAGER
Edit File: outer.html
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><title>R: Outer Product of Arrays</title> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <link rel="stylesheet" type="text/css" href="R.css" /> </head><body> <table width="100%" summary="page for outer {base}"><tr><td>outer {base}</td><td style="text-align: right;">R Documentation</td></tr></table> <h2>Outer Product of Arrays</h2> <h3>Description</h3> <p>The outer product of the arrays <code>X</code> and <code>Y</code> is the array <code>A</code> with dimension <code>c(dim(X), dim(Y))</code> where element <code>A[c(arrayindex.x, arrayindex.y)] = FUN(X[arrayindex.x], Y[arrayindex.y], ...)</code>. </p> <h3>Usage</h3> <pre> outer(X, Y, FUN = "*", ...) X %o% Y </pre> <h3>Arguments</h3> <table summary="R argblock"> <tr valign="top"><td><code>X, Y</code></td> <td> <p>First and second arguments for function <code>FUN</code>. Typically a vector or array.</p> </td></tr> <tr valign="top"><td><code>FUN</code></td> <td> <p>a function to use on the outer products, found <em>via</em> <code><a href="match.fun.html">match.fun</a></code> (except for the special case <code>"*"</code>).</p> </td></tr> <tr valign="top"><td><code>...</code></td> <td> <p>optional arguments to be passed to <code>FUN</code>.</p> </td></tr> </table> <h3>Details</h3> <p><code>X</code> and <code>Y</code> must be suitable arguments for <code>FUN</code>. Each will be extended by <code><a href="rep.html">rep</a></code> to length the products of the lengths of <code>X</code> and <code>Y</code> before <code>FUN</code> is called. </p> <p><code>FUN</code> is called with these two extended vectors as arguments (plus any arguments in <code>...</code>). It must be a vectorized function (or the name of one) expecting at least two arguments and returning a value with the same length as the first (and the second). </p> <p>Where they exist, the [dim]names of <code>X</code> and <code>Y</code> will be copied to the answer, and a dimension assigned which is the concatenation of the dimensions of <code>X</code> and <code>Y</code> (or lengths if dimensions do not exist). </p> <p><code>FUN = "*"</code> is handled as a special case <em>via</em> <code>as.vector(X) %*% t(as.vector(Y))</code>, and is intended only for numeric vectors and arrays. </p> <p><code>%o%</code> is binary operator providing a wrapper for <code>outer(x, y, "*")</code>. </p> <h3>Author(s)</h3> <p>Jonathan Rougier</p> <h3>References</h3> <p>Becker, R. A., Chambers, J. M. and Wilks, A. R. (1988) <em>The New S Language</em>. Wadsworth & Brooks/Cole. </p> <h3>See Also</h3> <p><code><a href="matmult.html">%*%</a></code> for usual (<em>inner</em>) matrix vector multiplication; <code><a href="kronecker.html">kronecker</a></code> which is based on <code>outer</code>; <code><a href="Vectorize.html">Vectorize</a></code> for vectorizing a non-vectorized function. </p> <h3>Examples</h3> <pre> 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] </pre> <hr /><div style="text-align: center;">[Package <em>base</em> version 3.6.0 <a href="00Index.html">Index</a>]</div> </body></html>