An optimised version of split for the special case of splitting row indices into groups, as used by splitter_d.

split_indices(group, n = 0L)

Arguments

group

integer indices

n

largest integer (may not appear in index). This is hint: if the largest value of group is bigger than n, the output will silently expand.

Examples

split_indices(sample(10, 100, rep = TRUE))
#> [[1]]
#>  [1] 10 12 19 24 27 32 53 57 61 81 83 86 95 97
#> 
#> [[2]]
#> [1]  2  5 39 62 70 82 93 94 96
#> 
#> [[3]]
#> [1]  6 23 34 48 49 67 85
#> 
#> [[4]]
#>  [1]  9 11 15 17 21 31 52 54 68 69 77 84
#> 
#> [[5]]
#> [1]  1 14 33 40 73 78
#> 
#> [[6]]
#>  [1]  3 18 20 30 47 50 58 59 64 76 91 99
#> 
#> [[7]]
#> [1]   7  42  88  92 100
#> 
#> [[8]]
#>  [1]  4 13 26 28 44 45 46 55 65 71 72 87 98
#> 
#> [[9]]
#>  [1]  8 29 35 36 38 41 43 51 63 66 89 90
#> 
#> [[10]]
#>  [1] 16 22 25 37 56 60 74 75 79 80
#> 
split_indices(sample(10, 100, rep = TRUE), 10)
#> [[1]]
#>  [1] 17 49 52 56 59 66 78 80 81 85
#> 
#> [[2]]
#> [1]  3  6 72 74 93 94
#> 
#> [[3]]
#>  [1]  8 12 13 15 18 37 48 57 63 82 84
#> 
#> [[4]]
#> [1] 25 27 33 34 51 73 76 96
#> 
#> [[5]]
#>  [1]  1 20 22 36 39 50 61 68 71 83 95
#> 
#> [[6]]
#>  [1]  2  4 16 21 24 31 41 44 47 54 67 70 77 79 87 89
#> 
#> [[7]]
#> [1] 19 26 62 65 69 92
#> 
#> [[8]]
#>  [1] 10 14 23 32 46 53 55 60 97 99
#> 
#> [[9]]
#> [1] 28 30 35 40 64 75 88 90 98
#> 
#> [[10]]
#>  [1]   5   7   9  11  29  38  42  43  45  58  86  91 100
#>