my_gapminder: Gapminder data with statistics for countries and continents.

Description Usage Format See Also Examples

Description

Data includes babies per woman, CO2 emissions per person, child mortality, income, life expectancy, population, and more. @source http://www.gapminder.org/data/

Usage

1

Format

An object of class tbl_df (inherits from tbl, data.frame) with 1704 rows and 6 columns.

See Also

country_colors for a nice color scheme for the countries

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
str(gapminder)
head(gapminder)
summary(gapminder)
table(gapminder$continent)
aggregate(lifeExp ~ continent, gapminder, median)
plot(lifeExp ~ year, gapminder, subset = country == "Cambodia", type = "b")
plot(lifeExp ~ gdpPercap, gapminder, subset = year == 2007, log = "x")

if (require("dplyr")) {
gapminder %>%
  filter(year == 2007) %>%
  group_by(continent) %>%
  summarise(lifeExp = median(lifeExp))

# how many unique countries does the data contain, by continent?
gapminder %>%
  group_by(continent) %>%
  summarize(n_obs = n(), n_countries = n_distinct(country))

# by continent, which country experienced the sharpest 5-year drop in
# life expectancy and what was the drop?
gapminder %>%
  group_by(continent, country) %>%
  select(country, year, continent, lifeExp) %>%
  mutate(le_delta = lifeExp - lag(lifeExp)) %>%
  summarize(worst_le_delta = min(le_delta, na.rm = TRUE)) %>%
  filter(min_rank(worst_le_delta) < 2) %>%
  arrange(worst_le_delta)
}

anna-vasyura/STAT302package documentation built on Dec. 19, 2021, 3:39 a.m.