From: Deepayan Sarkar <deepayan.sarkar_at_gmail.com>

Date: Thu, 21 Jun 2007 13:19:36 -0700

R-help_at_stat.math.ethz.ch 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. Received on Thu 21 Jun 2007 - 20:26:52 GMT

Date: Thu, 21 Jun 2007 13:19:36 -0700

On 6/21/07, SÃ©bastien <pomchip_at_free.fr> wrote:

> Hi Hadley,

*>
**> Hopefully, my dataset won't be too hard to changed. Can I modify the
**> aspect of each group using your code (symbols for observed and lines for
**> predicted)?
**>
**> Sebastien
**>
**> hadley wickham a Ã©crit :
**> > Hi Sebastian,
**> >
**> > I think you need to rearrange your data a bit. Firstly, you need to
**> > put observed on the same footing as the different models, so you would
**> > have a new column in your data called value (previously observed and
**> > predicted) and a new model type ("observed"). Then you could do:
*

Yes, and ?make.groups (and reshape of course) could help with that. This might not be strictly necessary though.

However, I'm finding your pseudo-code confusing. Could you create a small example data set that can be used to try out some real code? Just from your description, I would have suggested something like

xyplot(Observed + Predicted ~ Time | Individuals + Model,

data = mydata, panel = panel.superpose.2, type = c("p", "l"), layout = c(0, nlevels(mydata$Individuals)), <...>)

If all you want is to plot one page at a time, there are easier ways to do that.

-Deepayan

*> >
*

> > xyplot(value ~ time | individauls, data=mydata, group=model)

*> >
**> > Hadley
**> >
**> >
**> > On 6/21/07, SÃ©bastien <pomchip_at_free.fr> wrote:
**> >> Dear R Users,
**> >>
**> >> I recently posted an email on this list about the use of data.frame and
**> >> overlaying multiple plots. Deepayan kindly indicated to me the
**> >> panel.superposition command which worked perfectly in the context of the
**> >> example I gave.
**> >> I'd like to go a little bit further on this topic using a more complex
**> >> dataset structure (actually the one I want to work on).
**> >>
**> >> >mydata
**> >> Plot Model Individuals Time Observed
**> >> Predicted
**> >> 1 1 A 1 0.05
**> >> 10 10.2
**> >> 2 1 A 1 0.10
**> >> 20 19.5
**> >> etc...
**> >> 10 1 B 1 0.05 10
**> >> 9.8
**> >> 11 1 B 1 0.10 20
**> >> 20.2
**> >> etc...
**> >>
**> >> There are p "levels" in mydata$Plot, m in mydata$Model, n in
**> >> mydata$Individuals and t in mydata$Time (Note that I probably use the
**> >> word levels improperly as all columns are not factors). Basically, this
**> >> dataset summarizes the t measurements obtained in n individuals as well
**> >> as the predicted values from m different modeling approaches (applied to
**> >> all individuals). Therefore, the observations are repeated m times in
**> >> the Observed columns, while the predictions appears only once for a
**> >> given model an a given individual.
**> >>
**> >> What I want to write is a R batch file creating a Trellis graph, where
**> >> each panel corresponds to one individual and contains the observations
**> >> (as scatterplot) plus the predicted values for all models (as lines of
**> >> different colors)... $Plot is just a token: it might be used to not
**> >> overload graphs in case there are too many tested models. The fun part
**> >> is that the values of p, m, n and t might vary from one dataset to the
**> >> other, so everything has to be coded dynamically.
**> >>
**> >> For the plotting part I was thinking about having a loop in my code
**> >> containing something like that:
**> >>
**> >> for (i in 1:nlevels(mydata$Model)) {
**> >>
**> >> subdata<-subset(mydata,mydata$Model=level(mydata$Model)[i])
**> >> xyplot(subset(Observed + Predicted ~ Time | Individuals, data =
**> >> subdata) #plus additionnal formatting code
**> >>
**> >> }
**> >>
**> >> Unfortunately, this code simply creates a new Trellis plot instead of
**> >> adding the model one by one on the panels. Any idea or link to a useful
**> >> command will wellcome.
**> >>
**> >> Sebastien
**> >>
**> >> ______________________________________________
**> >> R-help_at_stat.math.ethz.ch 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.
**> >>
**> >
**> >
**>
**> ______________________________________________
**> R-help_at_stat.math.ethz.ch 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.
**>
*

R-help_at_stat.math.ethz.ch 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. Received on Thu 21 Jun 2007 - 20:26:52 GMT

Archive maintained by Robert King, hosted by
the discipline of
statistics at the
University of Newcastle,
Australia.

Archive generated by hypermail 2.2.0, at Fri 22 Jun 2007 - 17:32:12 GMT.

*
Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help.
Please read the posting
guide before posting to the list.
*