Examples for 'base::grouping'


Grouping Permutation

Aliases: grouping

Keywords: manip

### ** Examples

(ii <- grouping(x <- c(1, 1, 3:1, 1:4, 3), y <- c(9, 9:1), z <- c(2, 1:9)))
 [1]  6  5  2  1  7  4 10  8  3  9
attr(,"ends")
 [1]  1  2  3  4  5  6  7  8  9 10
attr(,"maxgrpn")
[1] 1
attr(,"class")
[1] "grouping" "integer" 
## 6  5  2  1  7  4 10  8  3  9
rbind(x, y, z)[, ii]
  [,1] [,2] [,3] [,4] [,5] [,6] [,7] [,8] [,9] [,10]
x    1    1    1    1    2    2    3    3    3     4
y    5    6    9    9    4    7    1    3    8     2
z    5    4    1    2    6    3    9    7    2     8

[Package base version 4.2.3 Index]