【发布时间】:2020-02-13 15:29:24
【问题描述】:
我有一种有效的方法,一种无效的方法,我无法弄清楚后者有什么问题。这里:
library(tidyverse)
get_these <- c(`Ideal E` = "cut == 'Ideal' & color == 'E'",
`Good J` = "cut == 'Good' & color == 'J'")
# This works:
get_these %>%
map(rlang::parse_expr) %>%
map(function(pick_these)
diamonds %>%
filter(!!pick_these)) %>%
tibble(goods = .) %>%
mutate(wat = names(get_these))
# This does not:
tibble(pick_these = get_these %>%
map(rlang::parse_expr)) %>%
mutate(wat = names(get_these),
goods = list(diamonds)) %>%
mutate(goods = pmap(.l = dplyr::select(.,
goods,
pick_these),
.f = function(goods, pick_these) {
goods %>% filter(!!pick_these)
})) %>%
dplyr::select(goods, wat)
【问题讨论】: