Re: [R] Overlaying lattice graphs

From: Sébastien <pomchip_at_free.fr>
Date: Tue, 12 Jun 2007 16:46:50 -0400

Thanks for the information. These commands work perfectly fine and the ?panel.superpose help was most informative. If you don't mind, I will certainly come back to you as there will certainly be additionnal complexities in my datasets that I will be unable to handle (e.g. data in more than one data.frame, complex conditions...).

Sebastien

Deepayan Sarkar a écrit :

> On 6/11/07, Seb <pomchip_at_free.fr> wrote:

>> Hello
>>
>> I apologize in advance if this question has already be posted on the
>> list, although I could not find a relevant thread in the archives.
>>
>> I would like to overlay xyplots using different datasets for each plot.
>> I typically work on the following data.frame (mydata) structure
>>
>> >mydata
>> Drug Time Observed Predicted
>> 1 A 0.05 10 10.2
>> 2 A 0.10 20 19.5
>> etc...
>> 100 B 0.05 11 12.7
>> 101 B 0.10 35 36
>> etc...
>>
>> I want to plot the observed data as points and the predicted values as
>> lines. If I use the following commands, I don't have the possibility to
>> switch the "y" values from Observed for the scatterplot to Predicted for
>> the line.
>>
>> xyplot(Observed ~ Time | Drug, data = mydata, panel = function(x,y,
>> ...){
>> + panel.xyplot(x,y,...)
>> + panel.xyplot(x,y,type="l",...)})
>>
>> I wonder if this problem can be solved using the trellis.focus "family"
>> commands but I have a hard time to understand how they work.
>>

>> Please, let me know if a thread have already addressed this question.
>> Otherwise, I would grateful for any hint, comments or info you can
>> provide.
>
> There are several possible solutions. In your case, the simplest one
> would be something like (see ?panel.superpose for explanation):
>
> xyplot(Observed + Predicted ~ Time | Drug, data = mydata,
>       type = c("p", "l"), distribute.type = TRUE)
>
> This will work best if the Time values are ordered; otherwise you 
> could use
>
> type = c("p", "a")
>
> instead, which will be a little slower. Let us know if this doesn't
> give you what you want, preferably with a reproducible example
> illustrating why.
>
> -Deepayan
>
>

______________________________________________
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 Tue 12 Jun 2007 - 20:54:04 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 Tue 12 Jun 2007 - 21:32:35 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.