An embedded and charset-unspecified text was scrubbed... Name: not available URL: <https://stat.ethz.ch/pipermail/r-help/attachments/20090322/4b3c59c1/attachment-0002.pl>
using xyplot
2 messages · Santosh, Deepayan Sarkar
3 days later
On 3/22/09, Santosh <santosh2005 at gmail.com> wrote:
Dear R-sians!
I am trying generate a bunch of xyplots
library(lattice)
myPanel <- function(x,y,xl=range(x),yl=range(y),...) {
panel.xyplot(x,y, pch=20,col='blue',cex=0.7,xlim=xl,ylim=yl,...)
panel.abline(v=0, col='gray30',lty=2,lwd=1.5,...)
panel.loess(x,y,
span=2/3,family='gaussian',normalize=T,col='red',lwd=1.5,...)
# panel.lmline(x,y, col='red',lwd=1.5,...)
}
nms <- names(tmp7)[c(3:7,9)]
for (i in nms) {
tmp1 <- xyplot(i~pk, data=tmp7, # different y's in the loop; x is same for all
You probably want xyplot(as.formula(paste(i, "~ pk")), data=... here. -Deepayan
as.table=T,panel=myPanel,main=paste('PK vs',i,'- overall'))
pdf(paste("pkvs",i,"a.pdf",sep=""),w=10,h=8)
print(tmp1)
dev.off()
}
The above code does not seem to work. I was not able to use sapply with a
FUN=xyplot, either.
I was, however, able to generate the plots (with xyplot) when I hard-code
the index value!
Could you please help me troubleshooting the above code? If you can also
help with an alternate code using sapply, it would be helpful!
Thanks much in advance!
Regards,
Santosh
[[alternative HTML version deleted]]
______________________________________________ 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.