Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
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)
我们可能需要interp
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