EVOLUTION-MANAGER
Edit File: grouping.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: Grouping Permutation</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 grouping {base}"><tr><td>grouping {base}</td><td style="text-align: right;">R Documentation</td></tr></table> <h2>Grouping Permutation</h2> <h3>Description</h3> <p><code>grouping</code> returns a permutation which rearranges its first argument such that identical values are adjacent to each other. Also returned as attributes are the group-wise partitioning and the maximum group size. </p> <h3>Usage</h3> <pre> grouping(...) </pre> <h3>Arguments</h3> <table summary="R argblock"> <tr valign="top"><td><code>...</code></td> <td> <p>a sequence of numeric, character or logical vectors, all of the same length, or a classed <span style="font-family: Courier New, Courier; color: #666666;"><b>R</b></span> object.</p> </td></tr> </table> <h3>Details</h3> <p>The function partially sorts the elements so that identical values are adjacent. <code>NA</code> values come last. This is guaranteed to be stable, so ties are preserved, and if the data are already grouped/sorted, the grouping is unchanged. This is useful for aggregation and is particularly fast for character vectors. </p> <p>Under the covers, the <code>"radix"</code> method of <code><a href="order.html">order</a></code> is used, and the same caveats apply, including restrictions on character encodings and lack of support for long vectors (those with <i>2^31</i> or more elements). Real-valued numbers are slightly rounded to account for numerical imprecision. </p> <p>Like <code>order</code>, for a classed <span style="font-family: Courier New, Courier; color: #666666;"><b>R</b></span> object the grouping is based on the result of <code><a href="xtfrm.html">xtfrm</a></code>. </p> <h3>Value</h3> <p>An object of class <code>"grouping"</code>, the representation of which should be considered experimental and subject to change. It is an integer vector with two attributes: </p> <table summary="R valueblock"> <tr valign="top"><td><code>ends</code></td> <td> <p>subscripts in the result corresponding to the last member of each group</p> </td></tr> <tr valign="top"><td><code>maxgrpn</code></td> <td> <p>the maximum group size</p> </td></tr> </table> <h3>See Also</h3> <p><code><a href="order.html">order</a></code>, <code><a href="xtfrm.html">xtfrm</a></code>. </p> <h3>Examples</h3> <pre> (ii <- grouping(x <- c(1, 1, 3:1, 1:4, 3), y <- c(9, 9:1), z <- c(2, 1:9))) ## 6 5 2 1 7 4 10 8 3 9 rbind(x, y, z)[, ii] </pre> <hr /><div style="text-align: center;">[Package <em>base</em> version 3.6.0 <a href="00Index.html">Index</a>]</div> </body></html>