convert x (a vector) into a list according to the group information (another vector) of elements in x.

tolist_by_group(x, group, drop = F)

Arguments

x

a vector

group

a vector with equal length of x, providing group information of elements in x

drop

drop levels of x

Value

a list. Order of elements is controled by levels of group.

Examples

tolist_by_group(x = 1:10, group = c(rep("A", 5), rep("B", 5)))
#> $A #> [1] 1 2 3 4 5 #> #> $B #> [1] 6 7 8 9 10 #>