[R] Use different panel functions with lattice
ilai
keren at math.montana.edu
Sun Mar 11 00:07:25 CET 2012
Inline
On Sat, Mar 10, 2012 at 1:47 PM, Balaitous <balaitous at mailoo.org> wrote:
> Le samedi 10 mars 2012 à 12:25 -0700, ilai a écrit :
>> On Sat, Mar 10, 2012 at 9:33 AM, Balaitous <balaitous at mailoo.org> wrote:
>
> Var1 and Var2 are 2 two different observed variables (with different scales)
You might want to consider scales=list(y=list(relation='free')) in ?xyplot
> Var3 is the time
> Var4 is the point of observation
>
> I have also a Var5 for groups, but I just want groups for the Var1.
<snip>
>
> But I don't know how to make the test
> if(Varx)
> in the function panel.mypanel, because I need
>
> Var1 -> panel.superpose (It's OK)
> Var2 -> panel.lines (I don't want groups for this)
>
> (And I will have others variables with other panel functions to use)
>
Since outer=T (i.e. Var1 and Var2 are in different panels), at the
beginning of the panel or panel.groups function, try
if(packet.number() %in% 1:3) {
panel.rect(x,y,groups,...) # or whatever for panels 1:3
}
else{
panel.rect(x,y,groups,col=constant,...) # or some other stuff for panels 4:6
}
Hope that works better.
>> >
>> > Something like :
>> >
>> > panel.mypanel = function(x, y, ...) {
>> > if (Var1) panel.Var1Panel(x, y, ...)
>> > else panel.Var2Panel(x, y, ...)
>> > }
>> > xyplot(Var1+Var2~Var3|Var4, data=df, panel=panel.mypanel)
>> >
>> > (I have search with google, but I found nothing)
>> >
>> > Thanks
>> >
>> > ______________________________________________
>> > 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