[R-sig-teaching] Choice of graphics package

Ista Zahn istazahn at gmail.com
Fri Nov 27 21:37:36 CET 2015


On Nov 27, 2015 1:57 PM, "Randall Pruim" <rpruim at calvin.edu> wrote:
>
>
> A few comments about choosing a graphics system:
>
> For most introductory courses, one system will suffice.  The systems
mostly do not play well together, so there are time and cognitive
inefficiencies to introducing more than one and switching among them.
>
> Lattice is a good option if you primarily want standard sorts of plots
(histograms, boxplots, scatter plots, etc.) created from a single data
source.  This is especially true if you are going to use the formula
interface for other things in your course (like linear models), since often
you can move between the model and the plot by changing only the name of
the function:
>
>         bwplot(age ~ sex, data = mosaic::HELPrct)
>         t.test(age ~ sex, data = mosic::HELPrct)
>         lm(age ~ sex, data = mosaic::HELPrct)
>
> If you use the mosaic package, you can also do numerical summaries using
the same formula interface:
>
>         mean(age ~ sex, data = HELPrct)
>
> This allows me to introduce numerical and graphical summaries in a day
and lays a foundation for modeling.  For this reason, I generally introduce
lattice to beginners.
>
> The ability to easily create facets (i.e., sub-panels) is another
strength of lattice although this is only slightly harder in ggplot2.  The
default theme for lattice is not to my liking, but it is easy to create a
custom theme to fix that, and with a single command, the new theme applies
to all subsequent plots.  I usually use
>
>         trellis.par.set(theme = mosaic::col.mosaic())
>
> (Theming in ggplot2 generally requires you to do something to each plot,
one of the downsides of ggplot2.)

That is completely untrue. Whatever downsides ggplot2 may have, this is not
one of them.
>
> ggplot2 is a better system for creating novel graphical representations
or for layering from multiple data sources.    Since it is built on a
“grammar of graphics”, I think it is also more useful as a tool for
training your mind to think about how graphics are constructed and what
makes them work.  In courses where any of these strengths are more
important, I lean toward ggplot2.
>
> The use of ggplot2 is greatly enhanced by introducing dplyr to manipulate
data into the formats that ggplot2 likes.  (To some extent this is true of
lattice as well.)  dplyr is another step more challenging than either
lattice or ggplot2 for most students.
>
> I like and use both systems for different reasons.  I sometimes wish I
could use features of one when working with the other.  I think either can
be taught to beginners, but it will take a bit more effort and time to
teach ggplot2.  You may prefer to teach lattice first and pick an
appropriate time to migrate from lattice to ggplot2.
>
> If you decide on lattice but feel that you wish you could go a bit
farther without getting into writing custom panel functions, you might take
a look at packages like gridExtra, latticeExtra, and mosaic, each of which
adds some things to the lattice system.
>
> Hope that helps.
>
> —rjp
>
> PS.  If you like ggplot2, then keep an eye on ggvis.  ggvis is poised to
move from a solid proof of concept to a really robust graphical system.  In
some ways it will be ggplot done right (or at least done with the benefit
of the experience of having done ggplot).  It is built with interactive
plots in mind (and currently doesn’t have a direct way to create things
like PDFs, but that may change over the next year).
>
>
>
>
> > On Nov 26, 2015, at 11:33 AM, Drew Tyre <atyre2 at unl.edu> wrote:
> >
> > I use R to teach graduate students in the life sciences (mostly ecology
but branching out). So far I show students both lattice and base  graphics.
I like lattice graphics for exploration because of the ease of faceting
plots. I use base graphics for "production plots" because I find it easier
to tell people how to add things to a base plot (multiple lines etc). To do
that effectively with lattice graphics you have to learn how to write panel
functions, and that can be a mind bending experience (it was/is for me).
> >
> > I have not developed the facility with ggplot that I have with base
graphics, so I can't comment on it. I think if one comes to truly
understand the ggplot model it will be better/faster/easier than either
base or lattice graphics, but it's a new model. I don't know which will be
easier to teach to students hitting it "cold". I'd be interested in hearing
from people that have tried teaching ggplot to students with no prior
expeRience.
> >
> > --
> > Drew Tyre
> >
> > School of Natural Resources
> > University of Nebraska-Lincoln
> > 416 Hardin Hall, East Campus
> > 3310 Holdrege Street
> > Lincoln, NE 68583-0974
> >
> > phone: +1 402 472 4054
> > fax: +1 402 472 2946
> > email: atyre2 at unl.edu
> > http://snr.unl.edu/tyre
> > http://aminpractice.blogspot.com
> > http://www.flickr.com/photos/atiretoo
> >
> > ________________________________________
> > From: R-sig-teaching <r-sig-teaching-bounces at r-project.org> on behalf
of Granaas, Michael <Michael.Granaas at usd.edu>
> > Sent: Thursday, November 26, 2015 9:23 AM
> > To: R-sig-teaching
> > Subject: [R-sig-teaching] Choice of graphics package
> >
> > I am working with first year grad students in psychology and have
sloooooooowly been adding some R content to the course.  I do not have a
systematic plan and I haven't yet found the teaching related materials that
will be a good match to my particular course structure.
> >
> > I noticed Randall Pruim's comment:
> > "4) For teaching, the decision between base graphics, lattice, and
ggplot2 (and soon ggvis) is an important one to think through.  Depending
on the goals of the course, I can imagine good arguments for using lattice
or ggplot2.  I don’t find base graphics compelling for teaching and never
teach it to my students."
> >
> > Which caused me to wonder....which package should I be focusing on?
> >
> > For these students I am focused on fairly basic graphics such as
boxplots, histograms, scatterplots.  What are the pros/cons of the
different packages that I should consider as I work to be more planful in
my incorporation of R?
> >
> > Michael
> >
> > __________________________________________________________
> > Michael Granaas
mgranaas at usd.edu
> > Department of Psychology                           SL: VRprofessor
Resident
> > University of South Dakota
> > 414 E. Clark St                                             Phone: 605
677 5295
> > Vermillion, SD  57069                                 FAX: 605 677 3195
> > ____________________________________________________________
> > My Personal Pet Project:
http://maps.secondlife.com/secondlife/Kaseyo/226/38/77
> > Free classrooms for educators exploring Second Life
> > _______________________________________________
> > R-sig-teaching at r-project.org mailing list
> > https://stat.ethz.ch/mailman/listinfo/r-sig-teaching
> >
> > _______________________________________________
> > R-sig-teaching at r-project.org mailing list
> > https://stat.ethz.ch/mailman/listinfo/r-sig-teaching
>
> _______________________________________________
> R-sig-teaching at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-sig-teaching

	[[alternative HTML version deleted]]



More information about the R-sig-teaching mailing list