[R] ggplot2 argument handling odd
Sebastian Weber
sebastian.weber at physik.tu-darmstadt.de
Wed Mar 26 17:03:39 CET 2008
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
More information about the R-help
mailing list