I'd like to create a nested listed from a tibble, so the data is stored more efficiently and it is easier to extract information with subsetting.
I have a 3 column tibble like the following:
library(dplyr)
df <- tribble(
~a,~b,~c,
"a1", "b1", 1,
"a1", "b1", 2,
"a1", "b2", 1,
"a1", "b2", 2,
)
I'd like to convert this to a list identical to this:
list(a1 = list(b1 = 1:2, b2 = 1:2))
Does anyone know how I can do this please?
Thanks