Get startedGet started for free

Filtering for one year

The filter verb extracts particular observations based on a condition. In this exercise you'll filter for observations from a particular year.

This exercise is part of the course

Introduction to the Tidyverse

View Course

Exercise instructions

  • Add a filter() line after the pipe (%>%) to extract only the observations from the year 1957. Remember that you use == to compare two values.

Hands-on interactive exercise

Have a go at this exercise by completing this sample code.

library(gapminder)
library(dplyr)

# Filter the gapminder dataset for the year 1957
gapminder %>%
  
Edit and Run Code