I\'d like to pass a quoted string to a function that calls ggplot2.
library(magrittr); library(ggplot2)
g1 <- function( variable ) {
ggplot(mtcars, aes_
A work-around is to substitute a common name for the variable name of interest in your function:
g1 <- function( variable ) {
colnames(mtcars) <- gsub(variable, "variable", colnames(mtcars))
ggplot(mtcars, aes(x=wt, y=variable, size=carb)) +
geom_point() + ylab(variable)
}
variables <- c("mpg", "cyl", "disp")
variables %>%
lapply(g1)