For the exercice on Europe, miss the filtering part of Europe country and create the list of countries
The code should be the following one:
Exercise
Modify our for loop so that it:
- loops through countries in Europe only.
- plots the cumulative mean gdpPercap (Hint: Use the Data Wrangling Cheatsheet!)
- saves them to a new subfolder inside the (recreated) figures folder called "Europe".
Solution
dir.create("figures")
dir.create("figures/Europe")
## create a list of countries. Calculations go here, not in the for loop
gap_europe <- gapminder %>%
filter(continent == "Europe") %>%
mutate(gdpPercap_cummean = dplyr::cummean(gdpPercap))
country_list <- unique(gap_europe$country)