I want to generate list of tibble fron one tibble in the following codes.
tbl = tibble(id=1:10, a = rnorm(10), b = rnorm(10))
tbl_list = c("a", "b") %>% map(~ tbl %>% select(c("id", .)))
The output I want is
tbl_list
[[1]]
# A tibble: 2 x 2
id a
<int> <dbl>
1 1 -0.704
2 2 -0.917
[[2]]
# A tibble: 2 x 2
id a
<int> <dbl>
1 1 -0.704
2 2 -0.917
However, it shows the error message,
"c("id", .)
must evaluate to column positions or names, not a list" ,
so it seems that .
is not recognized a character, but a list
Could you tell me how to avoid this error?