I have a simple function, but its ggplot command does not work. The command works correctly if given from the 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 using aes_stringinstead aes; as well as using x=first, y=second. Things are improving and one point is built! The X and Y axes show the numbers associated with this point as a label. Builds only the first row. What is the problem. Thank you for your help.
source
share