EVOLUTION-MANAGER
Edit File: slice.index.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: Slice Indexes in an Array</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 slice.index {base}"><tr><td>slice.index {base}</td><td style="text-align: right;">R Documentation</td></tr></table> <h2>Slice Indexes in an Array</h2> <h3>Description</h3> <p>Returns a matrix of integers indicating the number of their slice in a given array. </p> <h3>Usage</h3> <pre> slice.index(x, MARGIN) </pre> <h3>Arguments</h3> <table summary="R argblock"> <tr valign="top"><td><code>x</code></td> <td> <p>an array. If <code>x</code> has no dimension attribute, it is considered a one-dimensional array.</p> </td></tr> <tr valign="top"><td><code>MARGIN</code></td> <td> <p>an integer vector giving the dimension numbers to slice by.</p> </td></tr> </table> <h3>Details</h3> <p>If <code>MARGIN</code> gives a single dimension, then all elements of slice number <code>i</code> with respect to this have value <code>i</code>. In general, slice numbers are obtained by numbering all combinations of indices in the dimensions given by <code>MARGIN</code> in column-major order. I.e., with <i>m_1</i>, ..., <i>m_k</i> the dimension numbers (elements of <code>MARGIN</code>) sliced by and <i>d_{m_1}</i>, ..., <i>d_{m_k}</i> the corresponding extents, and <i>n_1 = 1</i>, <i>n_2 = d_{m_1}</i>, ..., <i>n_k = d_{m_1} … d_{m_{k-1}}</i>, the number of the slice where dimension <i>m_1</i> has value <i>i_1</i>, ..., dimension <i>m_k</i> has value <i>i_k</i> is <i>1 + n_1 (i_1 - 1) + … + n_k (i_k - 1)</i>. </p> <h3>Value</h3> <p>An integer array <code>y</code> with dimensions corresponding to those of <code>x</code>. </p> <h3>See Also</h3> <p><code><a href="row.html">row</a></code> and <code><a href="col.html">col</a></code> for determining row and column indexes; in fact, these are special cases of <code>slice.index</code> corresponding to <code>MARGIN</code> equal to 1 and 2, respectively when <code>x</code> is a matrix. </p> <h3>Examples</h3> <pre> x <- array(1 : 24, c(2, 3, 4)) slice.index(x, 2) slice.index(x, c(1, 3)) ## When slicing by dimensions 1 and 3, slice index 5 is obtained for ## dimension 1 has value 1 and dimension 3 has value 3 (see above): which(slice.index(x, c(1, 3)) == 5, arr.ind = TRUE) </pre> <hr /><div style="text-align: center;">[Package <em>base</em> version 3.6.0 <a href="00Index.html">Index</a>]</div> </body></html>