LoslegenKostenlos loslegen

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).

Diese Übung ist Teil des Kurses

Programming with dplyr

Kurs anzeigen

Interaktive Übung

Versuche dich an dieser Übung, indem du diesen Beispielcode vervollständigst.

# Rows with less than 0 for any "perc_change" ending columns
imf_data %>%
  filter(___(.cols = ___, 
             .fns = ~ ___) %>% 
  select(country, year, ends_with("perc_change"))
Code bearbeiten und ausführen