[R] xyplot question

Duncan Murdoch murdoch.duncan at gmail.com
Wed Jan 19 23:08:34 CET 2011


On 11-01-19 4:54 PM, Saiwing Yeung wrote:
> Hi all,
>
> I had a weird problem with xyplot and I am wondering if anyone can help me figure out what's wrong here. Basically if I call xyplot() inside a function and I call quartz() after, then the previous xyplot() does not do anything. A short demo of the issue is like this:
>
>
> library(lattice)
> plot.trends<- function()
> {
> 	mat<- data.frame(cbind(rnorm(100), rnorm(100)))
> 	names(mat)<- c("x", "y")
> 	quartz()
> 	xyplot(y ~ x, data=mat)
> 	quartz() # plotting works if this line is removed
> }
> plot.trends()

This is a version of FAQ 7.22:  you need to tell R to print lattice 
graphics.  Without the next statement, the result would be auto-printed.

Duncan Murdoch

>
>
> * if I run this as is, the xyplot() doesn't do anything, I only see 2 empty quartz window
> * replacing quartz() with X11() doesn't help.
> * if the content of the function is copied and run directly then it works fine.
> * if the second quartz() statement is removed then it also works.
>
>
> Here is my system info.
> * R 2.12.0
> * R.app GUI 1.35 (5632) i386-apple-darwin9.8.0
> * lattice_0.19-17
>
>
> any suggestions? Thanks in advance!
>
> Saiwing Yeung
>
> ______________________________________________
> 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.



More information about the R-help mailing list