grouping 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.
grouping(…)
| Parameter | Description |
|---|---|
… |
a sequence of numeric, character or logical vectors, all of the same length, or a classed R object. |
# NOT RUN {
(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]
# }