How do I remove the null elements from a list of lists, like below, in R:
lll <- list(list(NULL),list(1),list(\"a\"))
The object I want
Using purrr
purrr
purrr::map(lll, ~ purrr::compact(.)) %>% purrr::keep(~length(.) != 0) [[1]] [[1]][[1]] [1] 1 [[1]][[2]] [1] 2 [[1]][[3]] [1] 3 [[2]] [[2]][[1]] [1] "a" [[2]][[2]] [1] "b" [[2]][[3]] [1] "c"