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@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.

Reply via email to