Data Visualization
Objectives
Now that we have our programming foundation in place, let’s revisit our goal of making our work reproducible, shareable, and beautiful. This week, we’ll discuss how to make data visualizations in R using the {ggplot2} package. This package will allow you to make a large variety of plots, which are useful for exploratory data analysis as well as for generating publication-quality figures. We’ll go over the most common types of data visualizations, as well as principles for when you should use one type of plot versus another.
Readings
You should read this chapter before you come to class:
- Applied Data Skills - Chapter 3: Data Visualization
We will also discuss content from this chapter:
- Applied Data Skills - Chapter 10: Customizing Visualizations
Slides
Slides have been adapted from the textbook readings using Claude AI.
In-class exercises
We will follow along with the examples given in the textbook. Create an R project called visualization, and save today’s work in a Quarto report called plots.qmd. We will also go over the dataset that you’ll use for your assignment this week.
Weekly assignment
This week, you will recreate figures from the following paper:
- Przybylski, A. K., & Weinstein, N. (2017). A Large-Scale Test of the Goldilocks Hypothesis: Quantifying the Relations Between Digital-Screen Use and the Mental Well-Being of Adolescents. Psychological Science, 28(2), 204-215. link
Your goal is to use ggplot to recreate Figures 1 and 2 from this paper as closely as possible. Use this Quarto file to get started (right-click > Save Link As). This file builds on what you already did for Data Summaries, and it will take care of the preliminary processing steps necessary to get the dataset ready for visualization.
See also the screentime page for more information about the dataset.
Final project preparation: Refer to the instructions for the final project. You should get started on finding an openly available dataset.
Optional for this week: Please include in your Quarto report a link to the dataset and a link to the associated paper. If you are not ready to narrow it down, then include a few possible options. You can change your mind later.