r-whisker

Converting data frame into deeply nested list

六月ゝ 毕业季﹏ 提交于 2019-12-23 09:59:17
问题 I'm trying to create a data structure that the whisker package expects, and I can't seem to figure out how create that structure from my data frame. Let's say I have the following data frame: library(dplyr) existing_format <- mtcars %>% select(carb, gear, cyl) %>% arrange(carb, gear, cyl) %>% distinct() ...I would like to go from existing_format to the following desired format (only first two elements of desired_format list are shown): desired_format <- list( list( carb = "1", gear = list(