Learn R Programming


title: The mosaic package

Purpose and design

The mosaic package is designed to facilitate the use of R in statistics and calculus instruction by providing a number of functions that (a) make many common tasks fit into a common template, and (b) simplify some tasks that would otherwise be too complicated for beginners.

Installation

You install from CRAN using

install.packages("mosaic")

or from github with

devtools::install_github("ProjectMOSAIC/mosaic", build_vignettes = TRUE)

If you want to try out our developmental code (the beta branch), use

devtools::install_github("ProjectMOSAIC/mosaic", ref="beta")

Some features of the mosaic package have been split off into auxiliary packages. These include:

  • mosaicModel -- implements high-level systems for working with statistical models: effect-size calculation, bootstrapped confidence intervals, prediction error, graphics for models with multiple inputs. The package contains an introductory vignette.
  • mosaicCalc -- provides the calculus components of mosaic, including integration, differentiation, and differential equation solving.

Install these packages using install.packages(c("mosaicCalc", "mosaicModel")) or from GitHub as described above.

Updates to the master github repository are more frequent than CRAN updates. Our beta branch is where we implement bug fixes most quickly and develop new features. We try to keep it pretty stable, but there may be a few rough edges, missing documentation, etc. while things are in progress.

If you discover a problem with any version of the package, be sure to let us know so that we can address it. Post an issue on github or send email to Rpkgs@mosaic-web.org.

Getting Started with mosaic

The package includes several vignettes to help you get started. One of these vignettes (Resources Related to the mosaic package) includes a list of many resources, both within the package and external to it. That's a good place to start.

Getting Help

Need help? Try posting a question on Stack Overflow using the tag r-mosaic.

Project MOSAIC

Project MOSAIC is a community of educators working to develop a new way to introduce mathematics, statistics, computation and modeling to students in colleges and universities.

Our goal: Provide a broader approach to quantitative studies that provides better support for work in science and technology. The focus of the project is to tie together better diverse aspects of quantitative work that students in science, technology, and engineering will need in their professional lives, but which are today usually taught in isolation, if at all.

  • Modeling. The ability to create, manipulate and investigate useful and informative mathematical representations of a real-world situations.
  • Statistics. The analysis of variability that draws on our ability to quantify uncertainty and to draw logical inferences from observations and experiment.
  • Computation. The capacity to think algorithmically, to manage data on large scales, to visualize and interact with models, and to automate tasks for efficiency, accuracy, and reproducibility.
  • Calculus. The traditional mathematical entry point for college and university students and a subject that still has the potential to provide important insights to today's students.

The name MOSAIC reflects the first letters --- M, S, C, C --- of these important components of a quantitative education. Project MOSAIC is motivated by a vision of quantitative education as a mosaic where the basic materials come together to form a complete and compelling picture.

Find out more about Project MOSAIC at [http://www.mosaic-web.org].

Copy Link

Version

Install

install.packages('mosaic')

Monthly Downloads

26,291

Version

1.9.2

License

GPL (>= 2)

Issues

Pull Requests

Stars

Forks

Maintainer

Randall Pruim

Last Published

July 30th, 2025

Functions in mosaic (1.9.2)

mean_

Aggregating functions
maggregate

Aggregate for mosaic
ashplot

Average Shifted Histograms
aggregatingFunction2

2-ary aggregating functions
as.xtabs

Convert objects to xtabs format
aggregatingFunction1

1-ary Aggregating functions
cdist

Central portion of a distribution
aggregatingFunction1or2

1- or 2-ary aggregating functions
binom.test

Exact Tests for Proportions
cor_test.formula

Alternative formula interface for cor.test
deg2rad

Convert between degrees and radians
compareMean

Defunct functions
cull_for_do

Cull objects used with do()
bargraph

Create bar graphs from raw data
fetchData

Defunct functions now in the fetch package
chisq

Extract Chi-squared statistic
confint

Confidence interval methods for output of resampling
fortify.hclust

mosaic tools for clustering
cnorm

Central Probability in a Normal or T Distribution
dpqrdist

Distribution wrapper
factorize

Conditionally convert vectors to factors
docFile

Return the path to a documentation file in a package
cross

Factor cross products
fav_stats

Some favorite statistical summaries
dotPlot

Dotplots
expandFun

Expand the left-hand side of a formula
design_plot

Interactively design plots
derivedVariable

Create new variables from logicals
getVarFormula

Extract data from a data frame using a formula interface
freqpolygon

Frequency Polygons
fitSpline

Fit splines to data
googleMap

Display a point on earth on a Google Map
inferArgs

Infer arguments
fitModel

Fit a nonlinear least squares model
do

Do Things Repeatedly
fortify.summary.lm

Extract data from R objects
freqpoly

Turn histograms into frequency polygons
diffmean

Difference in means and proportions
findZerosMult

Find the zeros of a function of two or more variables
leaflet_map

Simple Leaflet Maps
xyz2latlon

Convert back and forth between latitude/longitude and XYZ-space
mPlot

Interactive plotting
is.wholenumber

Check for whole number values
findZeros

Find zeros of functions
ladd

Add to Lattice Plots
mWorldMap

Make a world map with ggplot2
makeColorscheme

Create a color generating function from a vector of colors
confint.htest

Extract summary statistics
mUSMap

Make a US map with ggplot2
.is.formula

Check if formula
panel.levelcontourplot

Lattice plot that draws a filled contour plot
linear.algebra

Functions for teaching linear algebra.
panel.lmbands

show confidence and prediction bands on plots
makeMap

Make a map with ggplot2
mosaic-package

mosaic: the Project MOSAIC package
orrr

Odds Ratio and Relative Risk for 2 x 2 Contingency Tables
ntiles

Create vector based on roughly equally sized groups
plotDist

Plots of Discrete and Continuous Distributions
mplot

Generic plotting
mosaic.options

Setting options for mosaic package functions
plotFun

Plotting mathematical expressions
qdata

The Data Distribution
pdist

Illustrated probability calculations from distributions
plotCumfreq

Cumulative frequency plots
relm

Resample a Linear Model
qdata_v

The Data Distribution
reexports

Objects exported from other packages
plotModel

Plot a regression model
plotPoints

Scatter plot of points
read.file

Read data files
prop_test

Internal function for testing proportion
rand

Random Regressors
panel.plotFun1

Panel function for plotting functions
panel.plotFun

Panel function for plotting functions
repeater-class

Repeater objects
mid

midpoints along a sequence
resample

More Random Samples
project

Projections
rsquared

Extract r-squared value
prop.test

Exact and Approximate Tests for Proportions
rstudio_is_available

Check whether RStudio is in use
rescale

Rescale
sp2df

Transforms a shapefile into a dataframe
set.rseed

Set seed in parallel compatible way
rflip

Tossing Coins
theme.mosaic

Lattice Theme
theme_map

ggplot2 theme for maps
rspin

Simulate spinning a spinner
qdist

Illustrated quantile calculations from distributions
rlatlon

Sample longitude and latitude on a sphere
standardName

Standardization of Geographic Names
xpnorm

Augmented versions of pnorm and qnorm
surround

Format strings for pretty output
swap

Swap values among columns of a data frame
xhistogramBreaks

Augmented histograms
update_ci

Update confidence interval
t_test

Student's t-Test
xqqmath

Augmented version of qqmath
value

Extract value from an object
rfun

Generate a natural-looking function
rgeo-internals

rgeo internal functions
statTally

Tally test statistics
xchisq.test

Augmented Chi-squared test
zscore

Compute z-scores
FunctionsFromData

Create function from data
Broyden

Multi-Dimensional Root Finding
CIsim

Compute confidence intervals from (multiple) simulated data sets
MAD_

All pairs mean and sum of absolute differences
MAD

All pairs mean and sum of absolute differences
CIAdata

Return a dataset based on the CIA World Factbook
TukeyHSD.lm

Additional interfaces to TukeyHSD
Mustangs

Mustang Prices
adapt_seq

Adaptively generate sequences in an interval
Sleep

Sleep and Memory