1 Preamble

Important Note: This is a previous version (v0.1.3) of ModernDive and may be out of date. For the current version of ModernDive, please go to ModernDive.com.

1.1 Principles of this Book - For Instructors

These are some principles we keep in mind. If you agree with them, this might be the book for you.

  1. Blur the lines between lecture and lab
    • Laptops and open source software are rendering the lab/lecture dichotomy ever more archaic.
    • It’s much harder for students to understand the importance of using the software if they only use it once a week or less. They forget the syntax in much the same way someone learning a foreign language forgets the rules.
  2. Focus on the entire data/science research pipeline
  3. It’s all about data, data, data
    • We leverage R packages for rich/complex, yet easy-to-load data sets.
    • We’ve heard it before: “You can’t teach ggplot2 for data visualization in intro stats!” We, like David Robinson, are more optimistic and we’ve had success doing so.
    • dplyr is a game changer for data manipulation: the verb describing your desired data action is the command name!
  4. Use simulation/resampling for intro stats, not probability/large sample approximation
    • Reinforce concepts, not equations, formulas, and probability tables.
    • To this end, we’re big fans of the mosaic package’s shuffle(), resample(), and do() functions for sampling and simulation.
  5. Don’t fence off students from the computation pool, throw them in!
    • Don’t teach them coding/programming per se, but computational and algorithmic thinking.
    • Drawing Venn diagrams delineating statistics, computer science, and data science is also ever more archaic; embrace computation!
  6. Complete reproducibility
    • We find it frustrating when textbooks give examples but not the source code and the data itself. We not only give you the source code for all examples, but also the source code for the whole book!
    • We encourage use of R Markdown to foster notions of reproducible research.
    • Ultimately the best textbook is one you’ve written yourself
      • You best know your audience, their background, and their priorities and you know best your own style and the types of examples and problems you like best. Customizability is the ultimate end.
      • A new paradigm for textbooks? Versions, not editions? Pull requests, crowd-sourcing, and development versions?

1.2 Contribute

  • This book is in beta testing and is currently at Version 0.1.3. If you would like to receive periodic updates on this book and other similar projects, please sign up here.
  • The source code for this book is available for download/forking on GitHub. If you click on the release link near the top of the page there, you can download all of the source code for whichever release version you’d like to work with and use. If you find typos or other errors or have suggestions on how to better word something in the book, please create a pull request too! We also welcome issue creation. Let’s all work together to make this book as great as possible for as many students and instructors as possible.
  • Please feel free to modify the book as you wish for your own needs! All we ask is that you list the authors field above as “Chester Ismay, Albert Y. Kim, and YOU!”
  • We’d also appreciate if you let us know what changes you’ve made and how you’ve used the textbook. We’d love some data on what’s working well and what’s not working so well.

1.3 Getting Started - For Students

This book was written using the bookdown R package from Yihui Xie (Xie 2017). In order to follow along and run the code in this book on your own, you’ll need to have access to R and RStudio. You can find more information on both of these with a simple Google search for “R” and for “RStudio.” An introduction to using R, RStudio, and R Markdown is also available in a free book here (Ismay 2016). It is recommended that you refer back to this book frequently as it has GIF screen recordings that you can follow along with as you learn.

We will keep a running list of R packages you will need to have installed to complete the analysis as well here in the needed_pkgs character vector. You can check if you have all of the needed packages installed by running all of the lines below in the next chunk of R code. The last lines including the if will install them as needed (i.e., download their needed files from the internet to your hard drive and install them for your use).

You can run the library function on them to load them into your current analysis. Prior to each analysis where a package is needed, you will see the corresponding library function in the text. Make sure to check the top of the chapter to see if a package was loaded there.

needed_pkgs <- c("nycflights13", "dplyr", "ggplot2", "knitr",
  "okcupiddata", "dygraphs", "rmarkdown", "mosaic",
  "ggplot2movies", "fivethirtyeight")

new.pkgs <- needed_pkgs[!(needed_pkgs %in% installed.packages())]

if(length(new.pkgs)) {
  install.packages(new.pkgs, repos = "http://cran.rstudio.com")


The source of the book is available here and was built with versions of R packages (and their dependent packages) given below. This may not be of importance for initial readers of this book, but the hope is you can reproduce a duplicate of this book by installing these versions of the packages.

package * version date source
assertthat 0.2.0 2017-04-11 cran ((???))
backports 1.1.0 2017-05-22 CRAN (R 3.3.2)
base64enc 0.1-3 2015-07-28 CRAN (R 3.3.0)
BH 1.62.0-1 2016-11-19 CRAN (R 3.3.2)
bindr 0.1 2016-11-13 cran ((???))
bindrcpp 0.2 2017-06-17 cran ((???))
bitops 1.0-6 2013-08-17 CRAN (R 3.3.0)
caTools 1.17.1 2014-09-10 CRAN (R 3.3.0)
colorspace 1.3-2 2016-12-14 CRAN (R 3.3.2)
dichromat 2.0-0 2013-01-24 CRAN (R 3.3.0)
digest 0.6.12 2017-01-27 CRAN (R 3.3.2)
dplyr 0.7.2 2017-07-20 CRAN (R 3.3.3)
dygraphs 2017-01-04 CRAN (R 3.3.2)
evaluate 0.10.1 2017-06-24 CRAN (R 3.3.2)
fivethirtyeight 2017-07-31 local
ggdendro 0.1-20 2016-04-27 CRAN (R 3.3.0)
ggformula 0.5 2017-07-24 CRAN (R 3.3.3)
ggplot2 2.2.1 2016-12-30 CRAN (R 3.3.2)
ggplot2movies 0.0.1 2015-08-25 CRAN (R 3.3.0)
glue 1.1.1 2017-06-21 cran ((???))
graphics * 3.3.3 2017-03-07 local
grDevices * 3.3.3 2017-03-07 local
grid 3.3.3 2017-03-07 local
gridExtra 2.2.1 2016-02-29 CRAN (R 3.3.0)
gtable 0.2.0 2016-02-26 CRAN (R 3.3.0)
highr 0.6 2016-05-09 CRAN (R 3.3.0)
hms 0.3 2016-11-22 CRAN (R 3.3.2)
htmltools 0.3.6 2017-04-28 cran ((???))
htmlwidgets 0.9 2017-07-10 CRAN (R 3.3.2)
jsonlite 1.5 2017-06-01 CRAN (R 3.3.2)
knitr 1.16.4 2017-05-30 Github (yihui/knitr@78e4d5d)
labeling 0.3 2014-08-23 CRAN (R 3.3.0)
lattice 0.20-35 2017-03-25 CRAN (R 3.3.2)
latticeExtra 0.6-28 2016-02-09 CRAN (R 3.3.0)
lazyeval 0.2.0 2016-06-12 CRAN (R 3.3.0)
magrittr 1.5 2014-11-22 CRAN (R 3.3.0)
markdown 0.8 2017-04-20 cran ((???))
MASS 7.3-47 2017-04-21 CRAN (R 3.3.2)
Matrix 1.2-10 2017-04-28 CRAN (R 3.3.2)
methods * 3.3.3 2017-03-07 local
mime 0.5 2016-07-07 CRAN (R 3.3.0)
mosaic 1.0.0 2017-07-26 CRAN (R 3.3.3)
mosaicCore 0.2.0 2017-07-24 CRAN (R 3.3.2)
mosaicData 0.14.0 2016-06-17 CRAN (R 3.3.0)
munsell 0.4.3 2016-02-13 CRAN (R 3.3.0)
nycflights13 0.2.2 2017-01-27 CRAN (R 3.3.2)
okcupiddata 0.1.0 2016-08-19 CRAN (R 3.3.0)
pkgconfig 2.0.1 2017-03-21 cran ((???))
plogr 0.1-1 2016-09-24 cran ((???))
plyr 1.8.4 2016-06-08 CRAN (R 3.3.0)
R6 2.2.2 2017-06-17 cran ((???))
RColorBrewer 1.1-2 2014-12-07 CRAN (R 3.3.0)
Rcpp 0.12.12 2017-07-15 cran ((???))
readr 1.1.1 2017-05-16 CRAN (R 3.3.2)
reshape2 1.4.2 2016-10-22 CRAN (R 3.3.0)
rlang 0.1.1 2017-05-18 cran ((???))
rmarkdown 1.6 2017-06-15 CRAN (R 3.3.2)
rprojroot 1.2 2017-01-16 CRAN (R 3.3.2)
scales 0.4.1 2016-11-09 CRAN (R 3.3.2)
splines 3.3.3 2017-03-07 local
stats * 3.3.3 2017-03-07 local
stringi 1.1.5 2017-04-07 cran ((???))
stringr 1.2.0 2017-02-18 cran ((???))
tibble 1.3.3 2017-05-28 cran ((???))
tidyr 0.6.3 2017-05-15 CRAN (R 3.3.2)
tools 3.3.3 2017-03-07 local
utils * 3.3.3 2017-03-07 local
xts 0.10-0 2017-07-07 CRAN (R 3.3.2)
yaml 2.1.14 2016-11-12 CRAN (R 3.3.2)
zoo 1.8-0 2017-04-12 CRAN (R 3.3.2)

Book was last updated by rudeboybert on Tuesday, August 01, 2017 19:14:36 EDT.


Xie, Yihui. 2017. Bookdown: Authoring Books and Technical Documents with R Markdown. https://CRAN.R-project.org/package=bookdown.

Ismay, Chester. 2016. Getting Used to R, RStudio, and R Markdown. http://ismayc.github.io/rbasics-book.