ggplot does not work in function, passing in variable names as strings
问题 I have following simple function but its ggplot command does not work. The command works all right when given from command line: > testfn <- function(gdf, first, second){ library(ggplot2) print(ggplot(gdf, aes(first, second)) + geom_point()) } > > testfn(mydataf, vnum1, vnum2) Error in eval(expr, envir, enclos) : object 'second' not found > > ggplot(mydataf, aes(vnum1, vnum2)) + geom_point() > (plots graph without any error) I tried to use aes_string instead of aes ; and also using x=first, y