This repository contains the materials for D-Lab's Data Wrangling workshop.
We recommend attending D-Lab's R Fundamentals series prior to this workshop.
Check D-Lab's Learning Pathways to figure out which of our workshops to take!
In this workshop, we provide practical guidance on data wrangling using
R's tidyverse
suite of packages. In Part 1, we cover how to
transform tidydata in order to perform data analysis and
visualization. In Part 2, we cover how to wrangle messy data into
tidy data.
After this workshop, you will be able to:
-
Use
tidyverse
functions for transforming your data to be used for visualization and analysis -
Identify how an "untidy" dataframe gets in the way of data visualization and analysis
-
Use
pivot_longer
andpivot_wider
to wrangle a dataframe into "tidy" form, and join multiple dataframes
This workshop does not cover the following:
- Data visualization in R (this is covered in D-Lab's R Data Visualization workshop)
- Advanced data analysis in R, such as machine learning (this is covered in D-Lab's R Machine Learning workshop)
We will use RStudio to go through the workshop materials, which requires installation of both the R language and the RStudio software.
-
Download R: Follow the links according to the operating system that you are running. Download the package, and install R onto your compute. You should install the most recent version (at least version 4.3).
-
Download RStudio: Install RStudio Desktop. This should be free. Do this after you have already installed R. The D-Lab strongly recommends an RStudio edition of 2022.02.0+443 "Prairie Trillium" or higher. Check RStudio is working by opening up the program.
-
Download these workshop materials:
-
Click the green "Code" button in the top right of the repository information.
-
Click "Download Zip".
-
Extract this file to a folder on your computer where you can easily access it (we recommend Desktop).
-
-
Optional: If you are familiar with
git
, you can instead clone this repository by opening a terminal and entering
If R/RStudio is not installing correctly or you do not wish to download these programs to your laptop, we strongly recommend using the UC Berkeley Datahub to run the materials for these lessons. You can access the DataHub by clicking the following button:
The DataHub downloads this repository, along with any necessary
packages, and allows you to run the materials in an RStudio instance on
UC Berkeley's servers. No installation is necessary from your end - you
only need an internet browser and a CalNet ID to log in. By using the
DataHub, you can save your work and come back to it at any time. When
you want to return to your saved work, just go straight to the D-Lab
DataHub, sign in, and you click on
the [Workshop-Name]
folder.
Check out the following resources to learn more about data wrangling in R:
- R for Data Science: A comprehensive
online textbook by Hadley Wickham, who helped develop
tidyverse
D-Lab works with Berkeley faculty, research staff, and students to advance data-intensive social science and humanities research. Our goal at D-Lab is to provide practical training, staff support, resources, and space to enable you to use R for your own research applications. Our services cater to all skill levels and no programming, statistical, or computer science backgrounds are necessary. We offer these services in the form of workshops, one-to-one consulting, and working groups that cover a variety of research topics, digital tools, and programming languages.
Visit the D-Lab homepage to learn more about us. You can view our calendar for upcoming events, learn about how to utilize our consulting and data services, and check out upcoming workshops.
Here are other R workshops offered by the D-Lab:
R Machine Learning (links to the pilot)