Dear R gurus.. Is it possible to control span settings for different values of a grouping variable, when using xyplot? an example code shown below d=data.frame(x=rep(sample(1:5,rep=F),10),y=rnorm(50),z=rep(sample(LETTERS[1:2],rep=F),25)) xyplot(y~x,data=d,groups=z,panel=panel.superpose,panel.groups=panel.loess(span=c(2/3, 3/4,1/2)) or something like.. xyplot(y~x,data=d,groups=z,panel=function(...) {panel.superpose(...);panel.groups=panel.loess(span=3/4,...)}) Thanks, Santosh [[alternative HTML version deleted]]
See ?panel.number for lattice functions that can be used in your panel function to discover which one is currently being drawn. On Thu, Apr 29, 2010 at 6:28 AM, Santosh <santosh2005 at gmail.com> wrote:> Dear R gurus.. > > Is it possible to control span settings for different values of a grouping > variable, when using xyplot? an example code shown below > d=data.frame(x=rep(sample(1:5,rep=F),10),y=rnorm(50),z=rep(sample(LETTERS[1:2],rep=F),25)) > xyplot(y~x,data=d,groups=z,panel=panel.superpose,panel.groups=panel.loess(span=c(2/3, > 3/4,1/2)) > or something like.. > xyplot(y~x,data=d,groups=z,panel=function(...) > {panel.superpose(...);panel.groups=panel.loess(span=3/4,...)}) > > Thanks, > Santosh > > ? ? ? ?[[alternative HTML version deleted]] > > ______________________________________________ > 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. >
Within panel.superpose, the current group number is passed as "group.number" to the "panel.groups" function. On 29 April 2010 20:39, Gabor Grothendieck <ggrothendieck at gmail.com> wrote:> See ?panel.number for lattice functions that can be used in your panel > function to discover which one is currently being drawn. > > On Thu, Apr 29, 2010 at 6:28 AM, Santosh <santosh2005 at gmail.com> wrote: >> Dear R gurus.. >> >> Is it possible to control span settings for different values of a grouping >> variable, when using xyplot? an example code shown below >> d=data.frame(x=rep(sample(1:5,rep=F),10),y=rnorm(50),z=rep(sample(LETTERS[1:2],rep=F),25)) >> xyplot(y~x,data=d,groups=z,panel=panel.superpose,panel.groups=panel.loess(span=c(2/3, >> 3/4,1/2)) >> or something like.. >> xyplot(y~x,data=d,groups=z,panel=function(...) >> {panel.superpose(...);panel.groups=panel.loess(span=3/4,...)}) >> >> Thanks, >> Santosh >> >> ? ? ? ?[[alternative HTML version deleted]] >> >> ______________________________________________ >> 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. >> > > ______________________________________________ > 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. >-- Felix Andrews / ??? Postdoctoral Fellow Integrated Catchment Assessment and Management (iCAM) Centre Fenner School of Environment and Society [Bldg 48a] The Australian National University Canberra ACT 0200 Australia M: +61 410 400 963 T: + 61 2 6125 4670 E: felix.andrews at anu.edu.au CRICOS Provider No. 00120C -- http://www.neurofractal.org/felix/
something like xyplot(y ~ x, data = d, groups = z, panel = panel.superpose, panel.groups = function(..., group.number) { panel.xyplot(...) span <- switch(group.number, 2/3, 1/4, 1/2) panel.loess(..., span = span) }, auto.key = list(lines = TRUE)) On Friday, April 30, 2010, Santosh <santosh2005 at gmail.com> wrote:> I could not make group.number work either..how do I get that? ...panel.superpose(panel.groups=group.number(),panel.bwplot,...) ? > > On Thu, Apr 29, 2010 at 4:26 PM, Felix Andrews <felix at nfrac.org> wrote: > Within panel.superpose, the current group number is passed as > "group.number" to the "panel.groups" function. > > > On 29 April 2010 20:39, Gabor Grothendieck <ggrothendieck at gmail.com> wrote: >> See ?panel.number for lattice functions that can be used in your panel >> function to discover which one is currently being drawn. >> >> On Thu, Apr 29, 2010 at 6:28 AM, Santosh <santosh2005 at gmail.com> wrote: >>> Dear R gurus.. >>> >>> Is it possible to control span settings for different values of a grouping >>> variable, when using xyplot? an example code shown below >>> d=data.frame(x=rep(sample(1:5,rep=F),10),y=rnorm(50),z=rep(sample(LETTERS[1:2],rep=F),25)) >>> xyplot(y~x,data=d,groups=z,panel=panel.superpose,panel.groups=panel.loess(span=c(2/3, >>> 3/4,1/2)) >>> or something like.. >>> xyplot(y~x,data=d,groups=z,panel=function(...) >>> {panel.superpose(...);panel.groups=panel.loess(span=3/4,...)}) >>> >>> Thanks, >>> Santosh >>> >>> ? ? ? ?[[alternative HTML version deleted]] >>> >>> ______________________________________________ >>> 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. >>> >> >> ______________________________________________ >> 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. >> > > > > -- > Felix Andrews / ??? > Postdoctoral Fellow > Integrated Catchment Assessment and Management (iCAM) Centre > Fenner School of Environment and Society [Bldg 48a] > The Australian National University > Canberra ACT 0200 Australia > M: +61 410 400 963 > T: + 61 2 6125 4670 > E: felix.andrews at anu.edu.au > CRICOS Provider No. 00120C > -- > http://www.neurofractal.org/felix/ > >