This document is intended to help users of the
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.
mosaic package used
graphics but now support is also available for the improved
ggformula system. Going forward,
will be the preferred graphics package for Project MOSAIC.
densityplot(~ age, data = HELPrct, groups = sex, auto.key = TRUE)
### Density over histograms (lattice)
mosaic makes it easy to add a fitted distribution to a
histogram(~ age, data = HELPrct, fit = "normal", dcol = "red")
gf_point(cesd ~ age, data = HELPrct, color = ~ sex) %>% gf_lm()
xyplot(cesd ~ age, data = HELPrct, groups = sex, type = c("p", "r"), auto.key = TRUE)
gf_point(cesd ~ age | sex, data = HELPrct) %>% gf_smooth(se = FALSE)
xyplot(cesd ~ age | sex, data = HELPrct, type = c("p", "smooth"), auto.key = TRUE)
xyplot(cesd ~ age, groups = sex, type = c("p", "r"), auto.key = TRUE, main = "This is my lattice plot", xlab = "age (in years)", ylab = "CES-D measure of depressive symptoms", data = HELPrct)
Within RStudio, after loading the
mosaic package, try
running the command
ds is a
dataframe. This will open up an interactive visualizer that will output
the code to generate the figure (using
ggformula) when you click on
More information about
ggformula can be found at https://www.mosaic-web.org/ggformula.
More information regarding Project MOSAIC (Kaplan, Pruim, and Horton)
can be found at http://www.mosaic-web.org. Further information regarding
mosaic package can be found at https://www.mosaic-web.org/mosaic and https://journal.r-project.org/archive/2017/RJ-2017-024.
Examples of how to bring multidimensional graphics into day one of an introductory statistics course can be found at https://escholarship.org/uc/item/84v3774z.