library(dplyr)
specials <- names(mtcars)[1:2]
specials[1]
i=1
设置完成, 这有效......
mtcars %>%
select_(specials[i], ~gear, ~carb)
为什么nse在添加过滤器时失败?
mtcars %>%
select_(specials[i], ~gear, ~carb) %>%
filter_(specials[i] == 21.4)
答案 0 :(得分:1)
我们可能需要interp
library(lazyeval)
library(dplyr)
mtcars %>%
select_(specials[i], ~gear, ~carb) %>%
filter_(interp(~nm == 21.4, nm = as.name(specials[1])))
# mpg gear carb
#1 21.4 3 1
#2 21.4 4 2