[R] ggplot2 argument handling odd

From: Sebastian Weber <sebastian.weber_at_physik.tu-darmstadt.de>
Date: Wed, 26 Mar 2008 17:03:39 +0100


Hello there,

I'm trying to do lots of plots in one for-loop. But somehow ggplot does not evaluate arguments as expected. Here is an example:

library(lattice)
library(ggplot2)
pl <- list()
pl2 <- list()
cDat <- as.data.frame(cbind(x1=0:100,x2=0:10,x3=1:20)) for(obs in c("x1", "x2")) {
  pl[[obs]] <- xyplot(cDat[,obs] ~ cDat[,"x3"], main=obs)   pl2[[obs]] <- qplot(cDat[,"x3"], cDat[,obs], main=obs) }

The pl list contains finally my desired result pl$x1 and pl$x2 are different and show what I want it to. Now, the plots pl2$x1 and pl2$x2 are the same - they both show an x2 ~ x3 plot since this is the current value of obs. So how can I force the variable name substitution? I tried some combinations of parse/eval/substitute with no success.

Thanks for your help in advance.

Greetings,

Sebastian Weber



R-help_at_r-project.org 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. Received on Wed 26 Mar 2008 - 16:13:29 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Wed 26 Mar 2008 - 21:30:24 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.

list of date sections of archive