I want to plot different variables against mpg
in data mtcars
, I want to plot them one by one, and wait for my any input for next plot, so I tried:
library(ggplot2)
vars = list(quote(wt), quote(cyl), quote(disp))
plot_fun <- function(var) {
qplot(mpg, eval(var), data=mtcars)
input <- readLines(n=1)
}
lapply(vars, plot_fun)
it doesn't plot anything, anybody can show me the correct way?