Get startedGet started for free

One for any, one for all

You can use the if_any() and if_all() functions with select() helper verbs to check for conditions being met across any or all columns. You'll again work with imf_data to return different subsets of rows according to different numeric conditions. Here you will focus on looking for years in which imports and exports increased or decreased from the previous year.

Recall the between() function in dplyr can be useful for specifying a range of values (from one to another).

This exercise is part of the course

Programming with dplyr

View Course

Hands-on interactive exercise

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

# Rows with less than 0 for any "perc_change" ending columns
imf_data %>%
  filter(___(.cols = ___, 
             .fns = ~ ___) %>% 
  select(country, year, ends_with("perc_change"))
Edit and Run Code