In: Statistics and Probability
Find the lifeExp in Europe across the years. Which year is the highest lifeExp in Europe?, in R command codes
library(gapminder)
library(dplyr)
gapminder %>% filter(continent=="Europe")
A tibble: 360 x 6 country continent year lifeExp pop gdpPercap <fct> <fct> <int> <dbl> <int> <dbl> 1 Albania Europe 1952 55.2 1282697 1601. 2 Albania Europe 1957 59.3 1476505 1942. 3 Albania Europe 1962 64.8 1728137 2313. 4 Albania Europe 1967 66.2 1984060 2760. 5 Albania Europe 1972 67.7 2263554 3313. 6 Albania Europe 1977 68.9 2509048 3533. 7 Albania Europe 1982 70.4 2780097 3631. 8 Albania Europe 1987 72 3075321 3739. 9 Albania Europe 1992 71.6 3326498 2497. 10 Albania Europe 1997 73.0 3428038 3193.
gapminder %>% filter(continent=="Europe") %>% arrange(desc(lifeExp))
A tibble: 360 x 6 country continent year lifeExp pop gdpPercap <fct> <fct> <int> <dbl> <int> <dbl> 1 Iceland Europe 2007 81.8 301931 36181. 2 Switzerland Europe 2007 81.7 7554661 37506. 3 Spain Europe 2007 80.9 40448191 28821. 4 Sweden Europe 2007 80.9 9031088 33860. 5 France Europe 2007 80.7 61083916 30470. 6 Switzerland Europe 2002 80.6 7361757 34481. 7 Italy Europe 2007 80.5 58147733 28570. 8 Iceland Europe 2002 80.5 288030 31163. 9 Italy Europe 2002 80.2 57926999 27968. 10 Norway Europe 2007 80.2 4627926 49357.
hence 2007 is highest lifeExp in Europe