0

I have nested list of tibbles and would like to convert it to a list of data.frames

starwars %>% select(homeworld , species , birth_year ) %>% nest_by(homeworld, .keep = F) %>% .$data

So in the example above there would be 49 data.frames in a list. How can I do this? It is important that the resulting list must be data.frames not tibbles, as the function I am using only accepts data.frames.

Tom
  • 131
  • 7
  • 1
    Once you have a list of tibbles, just call `as.data.frame` on them, e.g. using `purrr::map` or `lapply` – camille Sep 08 '21 at 16:44
  • This was the correct answer. I had tried %>% data.frame() but it makes sense I needed lapply. Shame the question was closed otherwise I would had upvoted. – Tom Sep 11 '21 at 09:04
  • You can still upvote an answer on a closed question – camille Sep 12 '21 at 01:39
  • I've upvoted your comment but it isn't written as an answer – Tom Sep 12 '21 at 23:13
  • No, I didn't post it as an answer because this needed to be marked as a duplicate instead – camille Sep 13 '21 at 01:16

1 Answers1

0

I think this might help

starwars %>%
 select(homeworld , species , birth_year ) %>%
 group_split(homeworld)
Vinícius Félix
  • 8,448
  • 6
  • 16
  • 32