I suspect this is a problem dealing with NSE. But why isn't these two approaches work and how can I get them to work.
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)