require(mosaic) # Load additional packages here require(ggformula) # Some customization. You can alter or delete as desired (if you know what you are doing). trellis.par.set(theme = theme.mosaic()) # change default color scheme for lattice theme_set(theme_bw()) # change default theme for ggformula knitr::opts_chunk$set( tidy = FALSE, # display code as typed size = "small") # slightly smaller font for code

This document is intended to help users of the `mosaic`

package migrate their `lattice`

package graphics to `ggformula`

. The mosaic package provides a simplified and systematic introduction to the core functionality related to descriptive statistics, visualization, modeling, and simulation-based inference required in first and second courses in statistics.

\newpage

\vspace*{.10in}
Originally, the `mosaic`

package used `lattice`

graphics but now support is also available for the improved `ggformula`

system. Going forward, `ggformula`

will be the preferred graphics
package for Project MOSAIC.

\vfill

\newpage

### Histograms (ggformula)
wzxhzdk:1
### Histogram options (ggformula)
wzxhzdk:2

\newpage
\vspace*{.03in}
### Histograms (lattice)
wzxhzdk:3
### Histogram options (lattice)
wzxhzdk:4

\newpage

### Density plots (ggformula)
wzxhzdk:5
### Overlaid density plots (ggformula)
wzxhzdk:6
### Density over histograms (ggformula)
We can use stacked layers to add a density curve based on a
maximum likelihood fit or a kernel density estimate (see also `gf_dist()`)
wzxhzdk:7

\newpage
\vspace*{.03in}
### Density plots (lattice)
wzxhzdk:8
### Overlaid density plots (lattice)
wzxhzdk:9
### Density over histograms (lattice)
`mosaic` makes it easy to add a fitted distribution to a histogram.
wzxhzdk:10

\newpage

### Side by side boxplots (ggformula)
wzxhzdk:11
### Faceted side by side boxplots (ggformula)
wzxhzdk:12
### Horizontal boxplots (ggformula)
wzxhzdk:13

\newpage
\vspace*{.03in}
### Side by side boxplots (lattice)
wzxhzdk:14
### Faceted side by side boxplots (lattice)
wzxhzdk:15
### Horizontal boxplots (lattice)
wzxhzdk:16

\newpage

### Basic scatterplot (ggformula)
wzxhzdk:17
### Overlaid scatterplot with linear fit (ggformula)
wzxhzdk:18
### Overlaid scatterplot with linear fit (lattice)
wzxhzdk:19

\newpage

### Faceted scatterplot with smooth fit (ggformula)
wzxhzdk:20

\newpage
## Faceted scatterplot with smooth fit (lattice)
wzxhzdk:21
## More options for scatterplot with linear fit (lattice)
wzxhzdk:22

\newpage

### Log scales (ggformula)
wzxhzdk:23
### Custom Colors (ggformula)
wzxhzdk:24

\newpage
\vspace*{.03in}
### Log scales (lattice)
wzxhzdk:25
### Custom Colors (lattice)
wzxhzdk:26

\newpage

Within RStudio, after loading the `mosaic`

package, try running the command `mplot(ds)`

where `ds`

is a dataframe. This will open up an interactive visualizer that will output the code to generate the figure (using `lattice`

, `ggplot2`

, or `ggformula`

) when you click on `Show Expression`

.

\newpage

More information about `ggformula`

can be found at https://projectmosaic/github.io/ggformula.

More information regarding Project MOSAIC (Kaplan, Pruim, and Horton) can be found at http://www.mosaic-web.org. Further information regarding the `mosaic`

package can be found at https://projectmosaic.github.io/mosaic and https://journal.r-project.org/archive/2017/RJ-2017-02.

Examples of how to bring multidimensional graphics into day one of an introductory statistics course can be found at http://escholarship.org/uc/item/84v3774z.

\vfill

**Any scripts or data that you put into this service are public.**

Embedding an R snippet on your website

Add the following code to your website.

For more information on customizing the embed code, read Embedding Snippets.