[R] Stratifying data with xyplot

Deepayan Sarkar deep@y@n@@@rk@r @end|ng |rom gm@||@com
Fri Mar 15 13:48:36 CET 2019


On Tue, Mar 12, 2019 at 2:28 AM Kevin Wright <kw.stat using gmail.com> wrote:
>
> See the examples here:
> https://www.stat.ubc.ca/~jenny/STAT545A/block10_latticeNittyGritty.html

Excellent reference. The only improvement I could think of is to abuse
the non-standard evaluation of 'groups' to avoid repeating the name of
the dataset, which would go something like

xyplot(lifeExp ~ gdpPercap | factor(year), yDat, aspect = 2/3,
       grid = TRUE, scales = list(x = list(log = 10, equispaced.log = FALSE)),
       col = jDarkGray, pch = jPch,
       groups = list(cex = sqrt(pop/pi) / jCexDivisor,
                     fill = color),
       panel = function(x, y, ..., groups, subscripts) {
           panel.xyplot(x, y,
                        cex = groups$cex[subscripts],
                        fill = groups$fill[subscripts], ...)
         })

Unfortunately, this doesn't work because prepanel.default.xyplot()
tries to be too smart and assumes that 'groups' is a factor. A
workaround is to override the default prepanel function; e.g.,

lattice.options(prepanel.default.xyplot =
                function(x, y, ...) list(xlim = extendrange(range(x)),
                                         ylim = extendrange(range(y))))

I will try to fix prepanel.default.xyplot() for the next update of lattice.

-Deepayan


>
> On Mon, Mar 11, 2019 at 2:26 PM Sebastien Bihorel <
> sebastien.bihorel using cognigencorp.com> wrote:
>
> > Hi,
> >
> > I am a big user/fan of the lattice package for plotting. As far as I know,
> > lattice only offers one method to stratify data within a xyplot panel,
> > using the groups arguments.
> > A contrario, the ggplot package allow users to use different variables for
> > coloring, setting the symbols, the line types or the size of symbols. This
> > frequently comes handy.
> > My question is whether any work has been done in the lattice ecosystem to
> > reproduce this functionality? If so, I would greatly appreciate any
> > pointers to the appropriate package documentation.
> >
> > Thank you
> >
> > Sebastien
> >
> > ______________________________________________
> > R-help using r-project.org mailing list -- To UNSUBSCRIBE and more, see
> > 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.
> >
>
>
> --
> Kevin Wright
>
>         [[alternative HTML version deleted]]
>
> ______________________________________________
> R-help using r-project.org mailing list -- To UNSUBSCRIBE and more, see
> 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