CO2_emissions: CO2 emissions per capita (metric tons of CO2)

Description Usage Format Source Examples

Description

Average CO2 emission in metric tons per person during the given year, calculated from deviding the total CO2 with the total population of the countries.

Usage

1

Format

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

Source

CDIAC (Carbon Dioxide Information Analysis Center) http://cdiac.ess-dive.lbl.gov/

Gapminder project, https://www.gapminder.org/

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
CO2_emissions %>% filter(year %in% c(1970, 1980, 1990, 2000, 2010)) %>%
  spread(year, emissions) %>% na.omit() -> emissions_1970_2010
ggplot(emissions_1970_2010, aes(`1970`, `2010`)) + geom_point() + scale_x_log10() + scale_y_log10() +
  geom_abline(slope = 1)

emissions_1970_2010 %>% mutate(diff = `2010` - `1970`) %>%
  arrange(desc(abs(diff))) -> emissions_diff

emissions_diff[1:10,] %>% select(-diff) %>% 
  gather(year, emissions, `1970`:`2010`) %>%
  mutate(year = as.numeric(year)) -> emissions_top_ten

ggplot(emissions_top_ten, aes(x = year, y = emissions, group = country)) + geom_point() + geom_line()

CO2_2010 <- gather(emissions_1970_2010, year, emissions, `1970`:`2010`) %>%
  filter(year == "2010") %>%
  select(-year) %>%
  rename(emissions2010 = emissions) %>% top_n(20)

CO2_ref2010 <- filter(CO2_emissions, year %in% c(1970, 1980, 1990, 2000, 2010)) %>%
  right_join(CO2_2010)

ggplot(CO2_ref2010, aes(x = year, y = emissions, group = country, color = emissions2010)) + 
  geom_point() + geom_line() + scale_color_viridis_c(option = "E", begin = 0.2, end = 0.9)

clauswilke/dviz.supp documentation built on Aug. 25, 2020, 2:12 a.m.