Splits a vector (which is casted as a factor) by its elements returning a
named list with the indices for each unique element of the vector.
Arguments
- x
A vector to split.
Value
A named list according to the unique elements of x
with the
integer indices of those given elements.
Examples
split0(letters[seq_len(3)])
#> $a
#> [1] 1
#>
#> $b
#> [1] 2
#>
#> $c
#> [1] 3
#>
## With some repeated info
set.seed(20161005)
abc <- sample(letters[seq_len(3)], 9, replace = TRUE)
split0(abc)
#> $a
#> [1] 1 3 8
#>
#> $b
#> [1] 2 5 7
#>
#> $c
#> [1] 4 6 9
#>