indexify.Rd
Create indexed components for the elements of a list.
indexify(x, out)
a numeric vector or list of vectors
string indicating the output format
("vector"
or "list"
)
A vector (or list) of indexed numbers
# let's say you have a numeric vector like this
num_vec = c(2, 3, 1, 4)
# get indices in vector format
indexify(num_vec)
#> [1] 1 1 2 2 2 3 4 4 4 4
# let's say you have a list like this
str_list = list(c("a","b","c"), c("d", "e"), c("f","g","h"))
# get indices in vector format
indexify(str_list)
#> [1] 1 1 1 2 2 3 3 3
# get indices in list format
indexify(str_list, "list")
#> [[1]]
#> [1] 1 1 1
#>
#> [[2]]
#> [1] 2 2
#>
#> [[3]]
#> [1] 3 3 3
#>