mosaic v0.14.4


Monthly downloads



by Randall Pruim

Project MOSAIC Statistics and Mathematics Teaching Utilities

Data sets and utilities from Project MOSAIC ( used to teach mathematics, statistics, computation and modeling. Funded by the NSF, Project MOSAIC is a community of educators working to tie together aspects of quantitative work that students in science, technology, engineering and mathematics will need in their professional lives, but which are usually taught in isolation, if at all.



CRAN_Status_Badge Travis-CI Build Status

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.


You install from CRAN using


or from github with


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

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

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

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 [].

Functions in mosaic

Name Description
mean_ Aggregating functions
aggregatingFunction1or2 1- or 2-ary aggregating functions
bargraph Create bar graphs from raw data
maggregate Aggregate for mosaic
ashplot Average Shifted Histograms
as.xtabs Convert objects to xtabs format
adapt_seq Adaptively generate sequences in an interval
Broyden Multi-Dimensional Root Finding
aggregatingFunction1 1-ary Aggregating functions
aggregatingFunction2 2-ary aggregating functions
D Derivative and Anti-derivative operators
columns return a vector of row or column indices
chisq Extract Chi-squared statistic
compareMean Compare means between 2 groups
compareProportion Compare proportions between 2 groups
cdist Central portion of a distribution
CIsim Compute confidence intervals from (multiple) simulated data sets
fortify.hclust mosaic tools for clustering
CIAdata Return a dataset based on the CIA World Factbook
coef.function Extract coefficients from a function
fetchData Defunct functions now in the fetch package
derivedVariable Create new variables from logicals
do Do Things Repeatedly
diffmean Difference in means and proportions
dfapply apply-type function for data frames
docFile Return the path to a documentation file in a package
deg2rad Convert between degrees and radians
deltaMethod deltaMethod has moved to a separate package
cross Factor cross products
cull_for_do Cull objects used with do()
fav_stats Some favorite statistical summaries
dotPlot Dotplots
dpqrdist Distribution wrapper
expandFun Expand the left-hand side of a formula
factorize Conditionally convert vectors to factors
evalSubFormula Evaluate a part of a formula
findZeros Find zeros of functions
findZerosMult Find the zeros of a function of two or more variables
ediff Lagged Differences with equal length
evalFormula Evaluate a formula
fitModel Fit a nonlinear least squares model
fitSpline Fit splines to data
FunctionsFromData Create function from data
StatSpline Geoms and stats for spline smoother
getVarFormula Extract data from a data frame using a formula interface
googleMap Display a point on earth on a Google Map
freqpolygon Frequency Polygons
freqpoly Turn histograms into frequency polygons
fortify.summary.lm Extract data from R objects
formularise Convert lazy objects into formulas
confint.htest Extract summary statistics
joinFrames Join data frames
is.wholenumber Check for whole number values
gwm Groupwise models Construct a model based on groupwise means or proportions
ladd Add to Lattice Plots
inferArgs Infer arguments
inspect Inspect objects
integrateODE Integrate ordinary differential equations
xyz2latlon Convert back and forth between latitude/longitude and XYZ-space
linear.algebra Functions for teaching linear algebra.
MAD All pairs mean and sum of absolute differences
mWorldMap Make a world map with ggplot2
makeColorscheme Create a color generating function from a vector of colors
n_missing counting missing elements
qdata The Data Distribution
qdata_v The Data Distribution
mosaic_formula Convert formulas into standard shapes
mid midpoints along a sequence
mplot Generic plotting
mm Construct a model based on groupwise means
named List extraction
pdist Illustrated probability calculations from distributions
nice_names Nice names
repeater-class Repeater objects
perctable Cross tabulation displayed as percents or proportions
resample More Random Samples
modelVars extract predictor variables from a model
print.msummary.lm Modified summaries
.is.formula Check if formula
mUSMap Make a US map with ggplot2
orrr Odds Ratio and Relative Risk for 2 x 2 Contingency Tables
panel.levelcontourplot Lattice plot that draws a filled contour plot
plotCumfreq Cumulative frequency plots
rescale Rescale
plotDist Plots of Discrete and Continuous Distributions
rflip Tossing Coins
relm Resample a Linear Model
reexports Objects exported from other packages
.polyExp Takes a call and returns its polynomial coefficients
sp2df Transforms a shapefile into a dataframe
zscore Compute z-scores
makeFun Create a function from a formula
ntiles Create vector based on roughly equally sized groups
makeMap Make a map with ggplot2
numD Numerical Derivatives
prop.test Exact and Approximate Tests for Proportions
prop Compute proportions, percents, or counts for a single level
rlatlon Sample longitude and latitude on a sphere
rkintegrate A simple Runge-Kutte integrator
xpnorm Augmented versions of pnorm and qnorm
MAD_ All pairs mean and sum of absolute differences
logical2factor Turn logicals into factors; leave other things alone
MSPE Mean Squared Prediction Error
panel.plotFun1 Panel function for plotting functions
plotModel Plot a regression model
parse.formula Parse formulas
plotPoints Scatter plot of points
rand Random Regressors
read.file Read data files
rspin Simulate spinning a spinnner
rsquared Extract r-squared value
symbolicD Symbolic Derivatives
symbolicInt Find the symbolic integral of a formula
xchisq.test Augmented Chi-squared test
xhistogram Augmented histograms
rfun Generate a natural-looking function
rgeo-internals rgeo internal functions
tally Tabulate categorical data
update_ci Update confidence interval
TukeyHSD.lm Additional interfaces to TukeyHSD
theme_map ggplot2 theme for maps
mosaic-package mosaic: the Project MOSAIC package
mosaic.options Setting options for mosaic package functions
panel.lmbands show confidence and preciction bands on plots
panel.plotFun Panel function for plotting functions
predict.groupwiseModel Evaluate a groupwise model given new data
project Projections
qdist Illustrated quantile calculations from distributions
standardName Standardization of Geographic Names
set.rseed Set seed in parallel compatible way
r.squared Extract r-squared value
rstudio_is_available Check whether RStudio is in use
statTally Tally test statistics
theme.mosaic Lattice Theme
t_test Student's t-Test
surround Format strings for pretty output
swap Swap values among columns of a data frame
vector2df Convert a vector to a data frame
value Extract value from an object
xqqmath Augmented version of qqmath
No Results!

Last month downloads


Type Package
Date 2016-07-29
VignetteBuilder knitr
License GPL (>= 2)
LazyLoad yes
LazyData yes
RoxygenNote 5.0.1
NeedsCompilation no
Packaged 2016-07-29 15:47:45 UTC; rpruim
Repository CRAN
Date/Publication 2016-07-29 19:07:11

Include our badge in your README