Hello, I am calling the following code with the loop! It makes 3 out graphs but empty! COuld you help me plase on that? Thank you in advance z1 <- dbConnect(MyData, "something", "A1", "A2") for (tt in c("xyz", "abc", "m1")) { message(paste("Here", tt, "!!!")) mydata <- dbReadTable(z1, tt) jpeg(file=paste("D:/", tt, ".jpg", sep=""), width=00, height=100) plot.method="bitmap" xyplot(MyVALUE ~ MyNo | as.character(ID), data = mydata, main = tt, xlab = " ", ylab = " ", type="l") dev.off() } --------------------------------- [[alternative HTML version deleted]]
When you call xyplot in a for loop you have to use the print command. For instance modifying the xyplot example: The following wont work: Depth <- equal.count(quakes$depth, number=8, overlap=.1) for(i in 1:3){xyplot(lat ~ long | Depth, data = quakes)} But this will: for(i in 1:3){print(xyplot(lat ~ long | Depth, data = quakes))} Regards Wayne -----Original Message----- From: r-help-bounces at r-project.org [mailto:r-help-bounces at r-project.org]On Behalf Of Samor Gandhi Sent: 01 October 2007 15:20 To: r-help at stat.math.ethz.ch Subject: [R] xyplot Hello, I am calling the following code with the loop! It makes 3 out graphs but empty! COuld you help me plase on that? Thank you in advance z1 <- dbConnect(MyData, "something", "A1", "A2") for (tt in c("xyz", "abc", "m1")) { message(paste("Here", tt, "!!!")) mydata <- dbReadTable(z1, tt) jpeg(file=paste("D:/", tt, ".jpg", sep=""), width=00, height=100) plot.method="bitmap" xyplot(MyVALUE ~ MyNo | as.character(ID), data = mydata, main = tt, xlab = " ", ylab = " ", type="l") dev.off() } --------------------------------- [[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.
It's a FAQ (7.22) -thomas On Mon, 1 Oct 2007, Samor Gandhi wrote:> Hello, > I am calling the following code with the loop! It makes 3 out graphs but empty! COuld you help me plase on that? Thank you in advance > > z1 <- dbConnect(MyData, "something", "A1", "A2") > for (tt in c("xyz", "abc", "m1")) { > message(paste("Here", tt, "!!!")) > mydata <- dbReadTable(z1, tt) > jpeg(file=paste("D:/", tt, ".jpg", sep=""), width=00, height=100) > plot.method="bitmap" > xyplot(MyVALUE ~ MyNo | as.character(ID), data = mydata, main = tt, xlab = " ", ylab = " ", type="l") > dev.off() > > } > > > --------------------------------- > > [[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. >Thomas Lumley Assoc. Professor, Biostatistics tlumley at u.washington.edu University of Washington, Seattle