Folks,
I want to automate some graphing using ggplot.
Here is my code
graphChargeOffs2<-function(coffs) {
ggplot(coffs, aes(levels))
dataNames<-names(coffs)[!names(coffs) == "levels"]
for(i in dataNames) {
thisData<-coffs[[i]]
last_plot() + geom_line(aes(y = thisData, colour = i))
}
last_plot() + ylab("Total Chargeoffs")
}
coffs is a data.frame.
I get the following error:
Error in eval(expr, envir, enclos) : object 'thisData' not found
As little as I know about environments in R I am pretty sure that the geom_line
in the loop is not able to see the thisData variable.
Any help you could provide would be appreciated. I would be surprised if there
wasn't a way to pass the data into the geom_line function without using
environments. Of course I have been wrong once or twice in the past. :)
Note that geom_line also can't see the input variable "coffs".
Thanks for any and all heo
--
[[alternative HTML version deleted]]
______________________________________________
[email protected] mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.