This intermediate course exposes students to the breadth of resources available in the R tidyverse to build their fluency and confidence when working in R. The tidyverse is a collection of libraries and functions in R sharing an underlying design (philosophy, grammar, and data structures) that aims to help users create efficient, “tidy” code. Many of the libraries address the common data wrangling tasks (read, select, filter, gather, spread, modify, recode, summarize) that are the precursors to both data analysis and visualization. Other libraries address specific tasks (e.g., ggplot2 to create graphs; purr to create functions; broom to tabulate model results) or specific data types (e.g., sf for spatial data, tibbletime for temporal data).
A mix of lectures and exercises will walk students through a series of increasingly complex data manipulation and visualization tasks. These exercises will emphasize the underlying principles and grammar of the tidyverse to help students transfer what they learn in the examples to their own research coding projects.
- Import tabular, spatial, and temporal data (readr, readxl, haven, sf, tibbletime)
- Manage data structure (dplyr, tidyr, magrittr, forcats, lubridate, stringr)
- Introduction to functional programming (purr)
- Visualize data and model results (broom, ggplot2)
Previous completion of an Introduction to R course and/or some experience using R is required.
Students must bring their own laptops with current versions of R (v3.4.3) and R Studio (v1.1.423) installed. We also recommend students pre-install the following packages: ggplot2, tidyr, dplyr, lubridate, scales, forcats, and sf.
Monday. R Review and Introduction to Tidyverse.
- Quick review of R and R Studio.
- Introduction to the Tidyverse philosophy and functions:
- positives and negatives
- core and peripheral Tidyverse functions
- Tidyverse options to import data (readr, readxl, haven, and others).
Tuesday. Data Visualization with ggplot2.
- Elements of a plot per the “Grammar of Graphics”:
- Aesthetic mapping, geometries, coordinates
- Groups and facets
- Scales and guides
- Aesthetic mapping as a driver of data manipulation.
Wednesday and Thursday. Data Wrangling in the Tidyverse.
- Restructure tabular data (tidyr).
- Row-wise and column-wise data manipulation (dplyr).
- Managing specific data classes (stringr, forcats, lubridate).
- Generate tabular summaries of model objects (broom).
- Introduction to spatial data in the tidyverse (sf).
- Introduction to time series in the tidyverse (tibbletime).
Friday. Functional Programming with purr.
- An introduction to functional programming concepts.
- Practice creating and applying functions (purr).
- Strategies to functionalize code and manage functions.