Wrangling data
23 February 2026
This week we get into working with data in R, demonstrating how to import data and wrangle it using the tidyverse.
Reading
- Kieran Healy, Data Visualization: A Practical Introduction, Chapter 3: Make a plot.
- Hadley Wickham et al., “Welcome to the Tidyverse,” Journal of Open Source Software 4, no. 43 (2019): 1686, https://doi.org/10.21105/joss.01686.
- Hadley Wickham et al., R for Data Science.
- Chapter 1: Data visualization
- Chapters 2 and 6 on working with R in RStudio.
- If you want to explore more on visualization with ggplot2, look at chapters 9, 10, and 11.
Assignment
- Create an R script named
intro-r.Rin yourr-notes/project folder and go through the material from one or more of the worksheets we have gone through in class.- The task is not necessarily to copy or do everything in the worksheets. Rather, play around with how things work using a script in RStudio.
- Get used to the differences of writing and running code in a script compared to directly in the console.
- Create objects, create vectors of different types, use different functions, look at documentation for functions with
?function_name.
- Create a GitHub account. You can follow these instructions from the Carpentries. Choose a username that you would be ok sharing in a professional environment. Mine is jessesadler, and so I can be found at https://github.com/jessesadler.
- Look through the course website repository and file an issue about something that could be improved or any questions you might have. It might be easiest to do this by looking at the course website and selecting Report an issue, which is usually on the right side of a page.
Activities
- Discussion: Working with scripts in R
- Importing data in R
- Wrangling data with dplyr
- Work through Data Carpentries, R for Social Scientists: Data Wrangling with dplyr
Resources
- Resources: Using R in RStudio
- Resources: Importing data
- Resources: Wrangling data in the tidyverse
- Worksheets: Wrangling data with dplyr
Importing data in R
- readr cheat sheet
- Wickham et al., R for Data Science
- Chapter 7: Data import
- Chapter 20: Spreadsheets
Wrangling data
- Introduction to dplyr
- Wickham et al., R for Data Science, Chapter 3: Data transformation.
- Data Carpentries, R for Social Scientists: Data Wrangling with dplyr