I would like to split a list according to each distinct element
mylist <- list("first","first","second")
### What I would like
# A first list
list("first","first")
# A second list
list("second")
If you do the one-liner:
list2env(split(mylist, unlist(mylist)), globalenv())
Then you have the two lists in your global environment:
dput(first)
#> list("first", "first")
dput(second)
#> list("second")
Created on 2023-01-25 with reprex v2.0.2