Dplyr :: nested data frame selection
I have the following example data frame:
library(tibble)
library(tidyverse)
df <- tibble(A = 1, B = 1)
df2 <- tibble(C = 2:4, D = 4:6)
df <- df %>%
nest(B) %>%
mutate(data = map(data, ~df2))
It is a nested dataframe 3x2
( df2
) in a dataframe 1x2
( df
). Is there a way to combine purrr::map
and dplyr::select
to select only column C
in a nested dataframe? I hope to avoid unnest
. The result should be:
A data
<dbl> <list>
1 1 <tibble [3 x 1]>
+3
source to share