Learning R: Dplyr

EC 320 - Introduction to Econometrics

Jose Rojas-Fallas

2025

Preview

So now you know how to build a dataset and run a regresion.

But sometimes you want to ask your dataset questions, like:

  • Which student got the highest final grade?
  • How much, on average, do “A” students study?
  • Out of all the students who finished the first semester with a “B”, how many of them turned it around to earn an “A” for their final grade?

In this lecture you will learn how to answer these questions and more using a toolset included in the tidyverse called dplyr. The name stands for data pliers and the idea is tha tyou should reach for your data pliers when you want to manipulate your data.

Functions

Dplyr Functions

dplyr is an amazing tool because, with just 7 main functions, you can answer just about any question you could possibly have about your data


If you have any data science experience, you will quickly realize that dplyr is nothing new.

It is actually just SQL, a language for querying databases that has been around since the ’70s.

We will not be write any SQL but you should know that by learning dplyr, you are also learning SQL.

The graphics for the functions were created by Colleen O’Briant

Practice: Download “Worksheet 03” From the Site

This worksheet will help you learn coding by doing. You will:

  • Practice how to do use all of these functions