From cowan.pd at gmail.com  Fri Jan 30 05:04:47 2009
From: cowan.pd at gmail.com (Peter Cowan)
Date: Thu, 29 Jan 2009 20:04:47 -0800
Subject: [Rd] How to generate a xyplot with multiple panels using an
	empty data frame ?
In-Reply-To: <332394640901291953t42c2192bs2b7eb337c205ec49@mail.gmail.com>
References: <332394640901291953t42c2192bs2b7eb337c205ec49@mail.gmail.com>
Message-ID: <e1fc21b0901292004l1b2163d1ra77a6c16858fd240@mail.gmail.com>

On Thu, Jan 29, 2009 at 7:53 PM, Daniel Kornhauser
<dkor at northwestern.edu> wrote:
> Hi:
>
> I am coding some interactive interface using an xyplot from lattice.
> When a user clicks on a panel of the xyplot, a simulation is executed and
> the resulting data is plotted on the corresponding panel.
> The problem is that I start with an empty data frame and only fill it as the
> user request data from simulations.
> And, I have found it impossible to create a conditional plot that contains
> panels using an empty data frame.
>
> For example I want:
>
> library(lattice)
> e = data.frame("a", "b", "c", "d")
> xyplot(X.a. ~ X.b. | X.c. + X.d., data = e, xlim = c(c(50,60),c(60,70)),
> ylim = c(c(10,20),c(20,30)), drop.unused.levels=FALSE,layout = c(2,2))
>
> to create a empty xyplot that would look like:
>
>       50             60           70
>        ----------------------------
>   10   |             |             |
>        |             |             |
>        |             |             |
>   20   ----------------------------
>        |             |             |
>        |             |             |
>   30   |             |             |
>        -----------------------------
>
> but it doesn't create 4 panels it only creates a single panel:
>
>        50    60      70
>        ---------------
>   10   |              |
>   20   |              |
>   30   |              |
>        ----------------
>
> I am a novice in R so I hope this is not a question that is too easy for the
> r-devel list.

I think you've directed your email to the wrong list.  R-devel, is
primarily targeted at people who write add-on packages (such as
lattice itself) or the R core.

Please see: <http://www.r-project.org/posting-guide.html#which_list>

This question should be directed to r-help which you can subscribe to here:

<http://www.r-project.org/mail.html>

>
>          Thanks.
>
>                    Daniel.
>
> PS: I got around this problem by creating "dummy" data frames containing
> data with the sole purpose of indicating xyplot the data rages.
>       It works well, but I consider it a hack.

If it that works, why do you consider it a hack?  There's probably a
more elegant way, but I would probably just make data frames, filled
with NA.

HTH

Peter



[Rd] How to generate a xyplot with multiple panels using an empty data frame ?
Peter Cowan