[R] Use different panel functions with lattice

ilai keren at math.montana.edu
Sat Mar 10 20:25:18 CET 2012


On Sat, Mar 10, 2012 at 9:33 AM, Balaitous <balaitous at mailoo.org> wrote:
> Hi,
>
> I have a data.frame df with
> names(df) = c("Var1", "Var2", "Var3", "Var4")
>
> and I plot data with
>
> xyplot(Var1+Var2~Var3|Var4, data=df)
>
> I want to use different panel functions for Var1 and Var2.
> How can I do ?

You didn't specify which "different panel functions" you want. Is
something like this what you're looking for?

 xyplot(Var1+Var2~Var3|Var4, data=df, panel=panel.superpose,
 panel.groups=function(x , y , group.number , ...){
 panel.xyplot(x , y[group.number==1] , ...)
 panel.lines(x , y[group.number==2] , lwd=2 , col=1)
})


>
> 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