EVOLUTION-MANAGER
Edit File: aperm.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: Array Transposition</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 aperm {base}"><tr><td>aperm {base}</td><td style="text-align: right;">R Documentation</td></tr></table> <h2>Array Transposition</h2> <h3>Description</h3> <p>Transpose an array by permuting its dimensions and optionally resizing it. </p> <h3>Usage</h3> <pre> aperm(a, perm, ...) ## Default S3 method: aperm(a, perm = NULL, resize = TRUE, ...) ## S3 method for class 'table' aperm(a, perm = NULL, resize = TRUE, keep.class = TRUE, ...) </pre> <h3>Arguments</h3> <table summary="R argblock"> <tr valign="top"><td><code>a</code></td> <td> <p>the array to be transposed.</p> </td></tr> <tr valign="top"><td><code>perm</code></td> <td> <p>the subscript permutation vector, usually a permutation of the integers <code>1:n</code>, where <code>n</code> is the number of dimensions of <code>a</code>. When <code>a</code> has named dimnames, it can be a character vector of length <code>n</code> giving a permutation of those names. The default (used whenever <code>perm</code> has zero length) is to reverse the order of the dimensions.</p> </td></tr> <tr valign="top"><td><code>resize</code></td> <td> <p>a flag indicating whether the vector should be resized as well as having its elements reordered (default <code>TRUE</code>).</p> </td></tr> <tr valign="top"><td><code>keep.class</code></td> <td> <p>logical indicating if the result should be of the same class as <code>a</code>.</p> </td></tr> <tr valign="top"><td><code>...</code></td> <td> <p>potential further arguments of methods.</p> </td></tr> </table> <h3>Value</h3> <p>A transposed version of array <code>a</code>, with subscripts permuted as indicated by the array <code>perm</code>. If <code>resize</code> is <code>TRUE</code>, the array is reshaped as well as having its elements permuted, the <code>dimnames</code> are also permuted; if <code>resize = FALSE</code> then the returned object has the same dimensions as <code>a</code>, and the dimnames are dropped. In each case other attributes are copied from <code>a</code>. </p> <p>The function <code>t</code> provides a faster and more convenient way of transposing matrices. </p> <h3>Author(s)</h3> <p>Jonathan Rougier, <a href="mailto:J.C.Rougier@durham.ac.uk">J.C.Rougier@durham.ac.uk</a> did the faster C implementation. </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="t.html">t</a></code>, to transpose matrices. </p> <h3>Examples</h3> <pre> # interchange the first two subscripts on a 3-way array x x <- array(1:24, 2:4) xt <- aperm(x, c(2,1,3)) stopifnot(t(xt[,,2]) == x[,,2], t(xt[,,3]) == x[,,3], t(xt[,,4]) == x[,,4]) UCB <- aperm(UCBAdmissions, c(2,1,3)) UCB[1,,] summary(UCB) # UCB is still a contingency table </pre> <hr /><div style="text-align: center;">[Package <em>base</em> version 3.6.0 <a href="00Index.html">Index</a>]</div> </body></html>