An optimised version of split for the special case of splitting row indices into groups.
split_indices(group, n = 0L)
A list of vectors of indices.
https://github.com/hadley/plyr/blob/d57f9377eb5d56107ba3136775f2f0f005f33aa3/src/split-numeric.cpp#L20
split_indices(sample(10, 100, rep = TRUE))
#> [[1]]
#> [1] 6 35 41 49 82 85 86 87 95 97
#>
#> [[2]]
#> [1] 2 16 32 47 54 57
#>
#> [[3]]
#> [1] 3 8 12 15 44 46 48 60 73 76 78 94 100
#>
#> [[4]]
#> [1] 10 21 22 26 27 30 34 37 40 66 67 84 90 91
#>
#> [[5]]
#> [1] 24 43 71 99
#>
#> [[6]]
#> [1] 23 28 33 50 51 58 68 98
#>
#> [[7]]
#> [1] 1 42 53 62 65 79 80 81 88
#>
#> [[8]]
#> [1] 4 5 7 17 19 20 29 36 39 45 63 64 74 77 83 89
#>
#> [[9]]
#> [1] 9 25 56 59 69 92 93
#>
#> [[10]]
#> [1] 11 13 14 18 31 38 52 55 61 70 72 75 96
#>
split_indices(sample(10, 100, rep = TRUE), 10)
#> [[1]]
#> [1] 4 11 13 23 34 44 69 76 78 89 97 99
#>
#> [[2]]
#> [1] 1 5 10 15 26 42 43 47 49 56 68 71 80
#>
#> [[3]]
#> [1] 9 18 29 38 55 57 72 83 84 87 98
#>
#> [[4]]
#> [1] 6 22 32 37 40 52 58 81 85
#>
#> [[5]]
#> [1] 7 33 54 77 92 93
#>
#> [[6]]
#> [1] 14 17 24 27 36 46 53 60 74
#>
#> [[7]]
#> [1] 3 16 30 51 59 63 66 73 79 100
#>
#> [[8]]
#> [1] 25 39 45 48 62 75 91 95 96
#>
#> [[9]]
#> [1] 31 35 41 61 65 67 86 88 94
#>
#> [[10]]
#> [1] 2 8 12 19 20 21 28 50 64 70 82 90
#>