Create new variables
Grouping and statistical functions
Joining datasets
12. Exercise 1


Great job! You've learned all we have in this section. Before we move on to the next chapter, let's have a quick summary. Remember what the following functions do?

  • filter() selects rows.
  • select() selects columns.
  • group_by() groups data for use in functions.
  • arrange() sorts data.
  • summarise(), mean(), and median() calculate statistics.
  • mutate() and transmute() create new columns.

We also met inner_join(), a way to combine data from two datasets.

You can combine various functions using the pipe operator (%>%). With the right functions, we can perform almost any operation on data.

Let's use a new dataset to practice what we know. We'll be working with data about students and their math, history, and geography exam results. The students are in five groups.

First, let's explore this data, starting with the math results.


First, exclude the name column from the students dataset. We won't be needing that. Filter rows relating to math from the exam column. Assign the result to the math variable. Remember to use the pipe operators!

Stuck? Here's a hint!


math <- students %>%
  select(-name) %>%
  filter(exam == "math")