我怀疑这是处理 NSE 的问题。但是为什么这两种方法不起作用,我怎样才能让它们起作用。
temp1 <- function(x){
iris %>%
ggplot(aes(Sepal.Length, Sepal.Width)) +
geom_point() +
facet_wrap(as.formula(paste("~", x)))
}
walk('Species', temp1)
temp2 <- function(x){
x <- as.name(x)
iris %>%
ggplot(aes(Sepal.Length, Sepal.Width)) +
geom_point() +
facet_wrap(~ x)
}
walk('Species', temp2)