NSF-funded project to develop a new way to introduce mathematics, statistics, computation and modeling to students in colleges and universities.
more information at mosaic-web.org
mosaic package is available via
This document was originally created as an R presentation to be used as slides accompanying various presentations. It has been converted into a more traditional document for use as a vignette in the
The examples below use the
mosaicData packages. An earlier version of this document used
lattice graphics, but it has been updated to use
library(mosaic) # loads mosaicData and ggformula as well
Many of the guiding principles of the
mosaic package reflect the “Less Volume, More Creativity” mantra of Mike McCarthy who had a large poster with those words placed in the “war room” (where assistant coaches decide on the game plan for the upcoming opponent) as a constant reminder not to add too much complexity to the game plan.
A lot of times you end up putting in a lot more volume, because you are teaching fundamentals and you are teaching concepts that you need to put in, but you may not necessarily use because they are building blocks for other concepts and variations that will come off of that … In the offseason you have a chance to take a step back and tailor it more specifically towards your team and towards your players."
Mike McCarthy, former Head Coach, Green Bay Packers
Perfection is achieved, not when there is nothing more to add, but when there is nothing left to take away.
— Antoine de Saint-Exupery (writer, poet, pioneering aviator)
One key to successfully introducing R is finding a set of commands that is
It is not enough to use R, it must be used elegantly.
Two examples of this principle:
Goal: a minimal set of R commands for Intro Stats
Result: Minimal R Vignette (
Much of the work on the
mosaic package has been motivated by
If you (or your students) are just getting started with R, it is good to keep the following in mind:
The following template is important because we can do so much with it.
It is useful to name the components of the template:
We’re hiding a bit of complexity in the template, and there will be times that we will want to gussy things up a bit. We’ll indicate that by adding
... to the end of the template. Just don’t let
... become a distractor early on.
Here are some variations on the template.
# simpler version goal(~ x, data = mydata) # fancier version goal(y ~ x | z , data = mydata) # unified version goal(formula, data = mydata)
Using the template generally requires answering two questions. (These questions are useful in the context of nearly all computer tools, just substitute “the computer” in for R in the questions.)
births ~ date)
data = Births78)
gf_point(births ~ date, data = Births78)
Some things you will need to know:
?HELPrctfor info about data
gf_boxplot(age ~ substance, data=HELPrct)