packages <- c("tidyverse", "srvyr", "broom","gt", "modelsummary",
"gapminder", "fst", "ggridges", "readxl", "readr","here")
new_packages <- packages[!(packages %in% installed.packages()[,"Package"])]
if(length(new_packages)) install.packages(new_packages)
lapply(packages, library, character.only = TRUE)
## ── Attaching core tidyverse packages ──────────────────────── tidyverse 2.0.0 ──
## ✔ dplyr 1.1.4 ✔ readr 2.1.5
## ✔ forcats 1.0.0 ✔ stringr 1.5.1
## ✔ ggplot2 3.5.1 ✔ tibble 3.2.1
## ✔ lubridate 1.9.4 ✔ tidyr 1.3.1
## ✔ purrr 1.0.2
## ── Conflicts ────────────────────────────────────────── tidyverse_conflicts() ──
## ✖ dplyr::filter() masks stats::filter()
## ✖ dplyr::lag() masks stats::lag()
## ℹ Use the conflicted package (<http://conflicted.r-lib.org/>) to force all conflicts to become errors
##
## Attaching package: 'srvyr'
##
##
## The following object is masked from 'package:stats':
##
## filter
##
##
## `modelsummary` 2.0.0 now uses `tinytable` as its default table-drawing
## backend. Learn more at: https://vincentarelbundock.github.io/tinytable/
##
## Revert to `kableExtra` for one session:
##
## options(modelsummary_factory_default = 'kableExtra')
## options(modelsummary_factory_latex = 'kableExtra')
## options(modelsummary_factory_html = 'kableExtra')
##
## Silence this message forever:
##
## config_modelsummary(startup_message = FALSE)
##
## here() starts at C:/Users/marco/OneDrive/R ecosystem/RStudio
## [[1]]
## [1] "lubridate" "forcats" "stringr" "dplyr" "purrr" "readr"
## [7] "tidyr" "tibble" "ggplot2" "tidyverse" "stats" "graphics"
## [13] "grDevices" "utils" "datasets" "methods" "base"
##
## [[2]]
## [1] "srvyr" "lubridate" "forcats" "stringr" "dplyr" "purrr"
## [7] "readr" "tidyr" "tibble" "ggplot2" "tidyverse" "stats"
## [13] "graphics" "grDevices" "utils" "datasets" "methods" "base"
##
## [[3]]
## [1] "broom" "srvyr" "lubridate" "forcats" "stringr" "dplyr"
## [7] "purrr" "readr" "tidyr" "tibble" "ggplot2" "tidyverse"
## [13] "stats" "graphics" "grDevices" "utils" "datasets" "methods"
## [19] "base"
##
## [[4]]
## [1] "gt" "broom" "srvyr" "lubridate" "forcats" "stringr"
## [7] "dplyr" "purrr" "readr" "tidyr" "tibble" "ggplot2"
## [13] "tidyverse" "stats" "graphics" "grDevices" "utils" "datasets"
## [19] "methods" "base"
##
## [[5]]
## [1] "modelsummary" "gt" "broom" "srvyr" "lubridate"
## [6] "forcats" "stringr" "dplyr" "purrr" "readr"
## [11] "tidyr" "tibble" "ggplot2" "tidyverse" "stats"
## [16] "graphics" "grDevices" "utils" "datasets" "methods"
## [21] "base"
##
## [[6]]
## [1] "gapminder" "modelsummary" "gt" "broom" "srvyr"
## [6] "lubridate" "forcats" "stringr" "dplyr" "purrr"
## [11] "readr" "tidyr" "tibble" "ggplot2" "tidyverse"
## [16] "stats" "graphics" "grDevices" "utils" "datasets"
## [21] "methods" "base"
##
## [[7]]
## [1] "fst" "gapminder" "modelsummary" "gt" "broom"
## [6] "srvyr" "lubridate" "forcats" "stringr" "dplyr"
## [11] "purrr" "readr" "tidyr" "tibble" "ggplot2"
## [16] "tidyverse" "stats" "graphics" "grDevices" "utils"
## [21] "datasets" "methods" "base"
##
## [[8]]
## [1] "ggridges" "fst" "gapminder" "modelsummary" "gt"
## [6] "broom" "srvyr" "lubridate" "forcats" "stringr"
## [11] "dplyr" "purrr" "readr" "tidyr" "tibble"
## [16] "ggplot2" "tidyverse" "stats" "graphics" "grDevices"
## [21] "utils" "datasets" "methods" "base"
##
## [[9]]
## [1] "readxl" "ggridges" "fst" "gapminder" "modelsummary"
## [6] "gt" "broom" "srvyr" "lubridate" "forcats"
## [11] "stringr" "dplyr" "purrr" "readr" "tidyr"
## [16] "tibble" "ggplot2" "tidyverse" "stats" "graphics"
## [21] "grDevices" "utils" "datasets" "methods" "base"
##
## [[10]]
## [1] "readxl" "ggridges" "fst" "gapminder" "modelsummary"
## [6] "gt" "broom" "srvyr" "lubridate" "forcats"
## [11] "stringr" "dplyr" "purrr" "readr" "tidyr"
## [16] "tibble" "ggplot2" "tidyverse" "stats" "graphics"
## [21] "grDevices" "utils" "datasets" "methods" "base"
##
## [[11]]
## [1] "here" "readxl" "ggridges" "fst" "gapminder"
## [6] "modelsummary" "gt" "broom" "srvyr" "lubridate"
## [11] "forcats" "stringr" "dplyr" "purrr" "readr"
## [16] "tidyr" "tibble" "ggplot2" "tidyverse" "stats"
## [21] "graphics" "grDevices" "utils" "datasets" "methods"
## [26] "base"
GHG_emissions <- read_excel("C:/Users/marco/OneDrive/R ecosystem/RStudio/owid-co2-data.xlsx")
glimpse(GHG_emissions)
## Rows: 50,191
## Columns: 79
## $ country <chr> "Afghanistan", "Afghanistan"…
## $ year <dbl> 1750, 1751, 1752, 1753, 1754…
## $ iso_code <chr> "AFG", "AFG", "AFG", "AFG", …
## $ population <dbl> 2802560, NA, NA, NA, NA, NA,…
## $ gdp <dbl> NA, NA, NA, NA, NA, NA, NA, …
## $ cement_co2 <dbl> 0, 0, 0, 0, 0, 0, 0, 0, 0, 0…
## $ cement_co2_per_capita <dbl> 0, NA, NA, NA, NA, NA, NA, N…
## $ co2 <dbl> NA, NA, NA, NA, NA, NA, NA, …
## $ co2_growth_abs <dbl> NA, NA, NA, NA, NA, NA, NA, …
## $ co2_growth_prct <dbl> NA, NA, NA, NA, NA, NA, NA, …
## $ co2_including_luc <dbl> NA, NA, NA, NA, NA, NA, NA, …
## $ co2_including_luc_growth_abs <dbl> NA, NA, NA, NA, NA, NA, NA, …
## $ co2_including_luc_growth_prct <dbl> NA, NA, NA, NA, NA, NA, NA, …
## $ co2_including_luc_per_capita <dbl> NA, NA, NA, NA, NA, NA, NA, …
## $ co2_including_luc_per_gdp <dbl> NA, NA, NA, NA, NA, NA, NA, …
## $ co2_including_luc_per_unit_energy <dbl> NA, NA, NA, NA, NA, NA, NA, …
## $ co2_per_capita <dbl> NA, NA, NA, NA, NA, NA, NA, …
## $ co2_per_gdp <dbl> NA, NA, NA, NA, NA, NA, NA, …
## $ co2_per_unit_energy <dbl> NA, NA, NA, NA, NA, NA, NA, …
## $ coal_co2 <dbl> NA, NA, NA, NA, NA, NA, NA, …
## $ coal_co2_per_capita <dbl> NA, NA, NA, NA, NA, NA, NA, …
## $ consumption_co2 <dbl> NA, NA, NA, NA, NA, NA, NA, …
## $ consumption_co2_per_capita <dbl> NA, NA, NA, NA, NA, NA, NA, …
## $ consumption_co2_per_gdp <dbl> NA, NA, NA, NA, NA, NA, NA, …
## $ cumulative_cement_co2 <dbl> 0, 0, 0, 0, 0, 0, 0, 0, 0, 0…
## $ cumulative_co2 <dbl> NA, NA, NA, NA, NA, NA, NA, …
## $ cumulative_co2_including_luc <dbl> NA, NA, NA, NA, NA, NA, NA, …
## $ cumulative_coal_co2 <dbl> NA, NA, NA, NA, NA, NA, NA, …
## $ cumulative_flaring_co2 <dbl> NA, NA, NA, NA, NA, NA, NA, …
## $ cumulative_gas_co2 <dbl> NA, NA, NA, NA, NA, NA, NA, …
## $ cumulative_luc_co2 <dbl> NA, NA, NA, NA, NA, NA, NA, …
## $ cumulative_oil_co2 <dbl> NA, NA, NA, NA, NA, NA, NA, …
## $ cumulative_other_co2 <lgl> NA, NA, NA, NA, NA, NA, NA, …
## $ energy_per_capita <dbl> NA, NA, NA, NA, NA, NA, NA, …
## $ energy_per_gdp <dbl> NA, NA, NA, NA, NA, NA, NA, …
## $ flaring_co2 <dbl> NA, NA, NA, NA, NA, NA, NA, …
## $ flaring_co2_per_capita <dbl> NA, NA, NA, NA, NA, NA, NA, …
## $ gas_co2 <dbl> NA, NA, NA, NA, NA, NA, NA, …
## $ gas_co2_per_capita <dbl> NA, NA, NA, NA, NA, NA, NA, …
## $ ghg_excluding_lucf_per_capita <dbl> NA, NA, NA, NA, NA, NA, NA, …
## $ ghg_per_capita <dbl> NA, NA, NA, NA, NA, NA, NA, …
## $ land_use_change_co2 <dbl> NA, NA, NA, NA, NA, NA, NA, …
## $ land_use_change_co2_per_capita <dbl> NA, NA, NA, NA, NA, NA, NA, …
## $ methane <dbl> NA, NA, NA, NA, NA, NA, NA, …
## $ methane_per_capita <dbl> NA, NA, NA, NA, NA, NA, NA, …
## $ nitrous_oxide <dbl> NA, NA, NA, NA, NA, NA, NA, …
## $ nitrous_oxide_per_capita <dbl> NA, NA, NA, NA, NA, NA, NA, …
## $ oil_co2 <dbl> NA, NA, NA, NA, NA, NA, NA, …
## $ oil_co2_per_capita <dbl> NA, NA, NA, NA, NA, NA, NA, …
## $ other_co2_per_capita <lgl> NA, NA, NA, NA, NA, NA, NA, …
## $ other_industry_co2 <lgl> NA, NA, NA, NA, NA, NA, NA, …
## $ primary_energy_consumption <dbl> NA, NA, NA, NA, NA, NA, NA, …
## $ share_global_cement_co2 <dbl> NA, NA, NA, NA, NA, NA, NA, …
## $ share_global_co2 <dbl> NA, NA, NA, NA, NA, NA, NA, …
## $ share_global_co2_including_luc <dbl> NA, NA, NA, NA, NA, NA, NA, …
## $ share_global_coal_co2 <dbl> NA, NA, NA, NA, NA, NA, NA, …
## $ share_global_cumulative_cement_co2 <dbl> NA, NA, NA, NA, NA, NA, NA, …
## $ share_global_cumulative_co2 <dbl> NA, NA, NA, NA, NA, NA, NA, …
## $ share_global_cumulative_co2_including_luc <dbl> NA, NA, NA, NA, NA, NA, NA, …
## $ share_global_cumulative_coal_co2 <dbl> NA, NA, NA, NA, NA, NA, NA, …
## $ share_global_cumulative_flaring_co2 <dbl> NA, NA, NA, NA, NA, NA, NA, …
## $ share_global_cumulative_gas_co2 <dbl> NA, NA, NA, NA, NA, NA, NA, …
## $ share_global_cumulative_luc_co2 <dbl> NA, NA, NA, NA, NA, NA, NA, …
## $ share_global_cumulative_oil_co2 <dbl> NA, NA, NA, NA, NA, NA, NA, …
## $ share_global_cumulative_other_co2 <lgl> NA, NA, NA, NA, NA, NA, NA, …
## $ share_global_flaring_co2 <dbl> NA, NA, NA, NA, NA, NA, NA, …
## $ share_global_gas_co2 <dbl> NA, NA, NA, NA, NA, NA, NA, …
## $ share_global_luc_co2 <dbl> NA, NA, NA, NA, NA, NA, NA, …
## $ share_global_oil_co2 <dbl> NA, NA, NA, NA, NA, NA, NA, …
## $ share_global_other_co2 <lgl> NA, NA, NA, NA, NA, NA, NA, …
## $ share_of_temperature_change_from_ghg <dbl> NA, NA, NA, NA, NA, NA, NA, …
## $ temperature_change_from_ch4 <dbl> NA, NA, NA, NA, NA, NA, NA, …
## $ temperature_change_from_co2 <dbl> NA, NA, NA, NA, NA, NA, NA, …
## $ temperature_change_from_ghg <dbl> NA, NA, NA, NA, NA, NA, NA, …
## $ temperature_change_from_n2o <dbl> NA, NA, NA, NA, NA, NA, NA, …
## $ total_ghg <dbl> NA, NA, NA, NA, NA, NA, NA, …
## $ total_ghg_excluding_lucf <dbl> NA, NA, NA, NA, NA, NA, NA, …
## $ trade_co2 <dbl> NA, NA, NA, NA, NA, NA, NA, …
## $ trade_co2_share <dbl> NA, NA, NA, NA, NA, NA, NA, …
co2_per_capita_countries <- GHG_emissions %>%
filter(year >= 1990 & year <= 2020) %>%
filter(!is.na(co2_per_capita))%>%
filter(country %in% c("Germany", "Poland", "France","Ireland")) %>%
select(year, country, co2_per_capita) %>%
group_by(country)
print(co2_per_capita_countries)
## # A tibble: 124 × 3
## # Groups: country [4]
## year country co2_per_capita
## <dbl> <chr> <dbl>
## 1 1990 France 6.91
## 2 1991 France 7.30
## 3 1992 France 7.08
## 4 1993 France 6.71
## 5 1994 France 6.56
## 6 1995 France 6.63
## 7 1996 France 6.89
## 8 1997 France 6.74
## 9 1998 France 7.03
## 10 1999 France 6.97
## # ℹ 114 more rows
co2_per_gdp_countries <- GHG_emissions %>%
filter(year >= 1990 & year <= 2020) %>%
filter(!is.na(co2_per_gdp))%>%
filter(country %in% c("Poland", "Germany", "Ireland", "France")) %>%
select(year, country, co2_per_gdp) %>%
group_by(country)
print(co2_per_gdp_countries)
## # A tibble: 124 × 3
## # Groups: country [4]
## year country co2_per_gdp
## <dbl> <chr> <dbl>
## 1 1990 France 0.241
## 2 1991 France 0.253
## 3 1992 France 0.242
## 4 1993 France 0.232
## 5 1994 France 0.222
## 6 1995 France 0.221
## 7 1996 France 0.227
## 8 1997 France 0.217
## 9 1998 France 0.22
## 10 1999 France 0.211
## # ℹ 114 more rows
energy_per_capita_countries <- GHG_emissions %>%
filter(year >= 1990 & year <= 2020) %>%
filter(!is.na(energy_per_capita))%>%
filter(country %in% c("Germany", "France", "Poland", "Ireland")) %>%
select(year, country, energy_per_capita) %>%
group_by(country)
print(energy_per_capita_countries)
## # A tibble: 124 × 3
## # Groups: country [4]
## year country energy_per_capita
## <dbl> <chr> <dbl>
## 1 1990 France 46972.
## 2 1991 France 50034.
## 3 1992 France 50259.
## 4 1993 France 50021.
## 5 1994 France 49358.
## 6 1995 France 50578.
## 7 1996 France 52277.
## 8 1997 France 51274.
## 9 1998 France 52293.
## 10 1999 France 52749.
## # ℹ 114 more rows
policy_stringency <- read_csv("C:/Users/marco/OneDrive/R ecosystem/RStudio/policy_stringency.csv")
## Rows: 155 Columns: 22
## ── Column specification ────────────────────────────────────────────────────────
## Delimiter: ","
## chr (16): STRUCTURE, STRUCTURE_ID, STRUCTURE_NAME, ACTION, REF_AREA, Referen...
## dbl (4): TIME_PERIOD, OBS_VALUE, UNIT_MULT, DECIMALS
## lgl (2): Time period, Observation value
##
## ℹ Use `spec()` to retrieve the full column specification for this data.
## ℹ Specify the column types or set `show_col_types = FALSE` to quiet this message.
glimpse(policy_stringency)
## Rows: 155
## Columns: 22
## $ STRUCTURE <chr> "DATAFLOW", "DATAFLOW", "DATAFLOW", "DATAFL…
## $ STRUCTURE_ID <chr> "OECD.ECO.MAD:DSD_EPS@DF_EPS(1.0)", "OECD.E…
## $ STRUCTURE_NAME <chr> "OECD Environmental Policy Stringency Index…
## $ ACTION <chr> "I", "I", "I", "I", "I", "I", "I", "I", "I"…
## $ REF_AREA <chr> "POL", "IRL", "IRL", "IRL", "IRL", "IRL", "…
## $ `Reference area` <chr> "Poland", "Ireland", "Ireland", "Ireland", …
## $ FREQ <chr> "A", "A", "A", "A", "A", "A", "A", "A", "A"…
## $ `Frequency of observation` <chr> "Annual", "Annual", "Annual", "Annual", "An…
## $ MEASURE <chr> "POL_STRINGENCY", "POL_STRINGENCY", "POL_ST…
## $ Measure <chr> "Policy stringency", "Policy stringency", "…
## $ CLIM_POL <chr> "EPS", "EPS", "EPS", "EPS", "EPS", "EPS", "…
## $ `Climate policies` <chr> "All environmental policies (EPS index)", "…
## $ TIME_PERIOD <dbl> 2002, 1998, 1997, 1996, 1995, 1994, 1993, 1…
## $ `Time period` <lgl> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA,…
## $ OBS_VALUE <dbl> 1.2777778, 0.9444444, 0.8888889, 0.8888889,…
## $ `Observation value` <lgl> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA,…
## $ UNIT_MULT <dbl> 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0…
## $ `Unit multiplier` <chr> "Units", "Units", "Units", "Units", "Units"…
## $ UNIT_MEASURE <chr> "0_TO_6", "0_TO_6", "0_TO_6", "0_TO_6", "0_…
## $ `Unit of measure` <chr> "0-6 scale", "0-6 scale", "0-6 scale", "0-6…
## $ DECIMALS <dbl> 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2…
## $ Decimals <chr> "Two", "Two", "Two", "Two", "Two", "Two", "…
policy_stringency_value <- policy_stringency %>%
filter(TIME_PERIOD >= 1990 & TIME_PERIOD <= 2020) %>%
filter(!is.na(OBS_VALUE), !is.na(TIME_PERIOD),
`Reference area` %in% c("Poland", "Germany", "Ireland", "France")) %>%
arrange(TIME_PERIOD) %>%
select(year = TIME_PERIOD,
country = `Reference area`,
stringency_value = OBS_VALUE)
print(policy_stringency_value)
## # A tibble: 124 × 3
## year country stringency_value
## <dbl> <chr> <dbl>
## 1 1990 Ireland 0.528
## 2 1990 Poland 0.583
## 3 1990 France 1.44
## 4 1990 Germany 1.44
## 5 1991 Ireland 0.472
## 6 1991 Poland 0.528
## 7 1991 France 1.33
## 8 1991 Germany 1.69
## 9 1992 Ireland 0.528
## 10 1992 Poland 0.583
## # ℹ 114 more rows
energy_data <- read_csv("C:/Users/marco/OneDrive/R ecosystem/RStudio/owid-energy-data.csv")
## Rows: 21812 Columns: 129
## ── Column specification ────────────────────────────────────────────────────────
## Delimiter: ","
## chr (2): country, iso_code
## dbl (127): year, population, gdp, biofuel_cons_change_pct, biofuel_cons_chan...
##
## ℹ Use `spec()` to retrieve the full column specification for this data.
## ℹ Specify the column types or set `show_col_types = FALSE` to quiet this message.
glimpse(energy_data)
## Rows: 21,812
## Columns: 129
## $ country <chr> "ASEAN (Ember)", "ASEAN (…
## $ year <dbl> 2000, 2001, 2002, 2003, 2…
## $ iso_code <chr> NA, NA, NA, NA, NA, NA, N…
## $ population <dbl> NA, NA, NA, NA, NA, NA, N…
## $ gdp <dbl> NA, NA, NA, NA, NA, NA, N…
## $ biofuel_cons_change_pct <dbl> NA, NA, NA, NA, NA, NA, N…
## $ biofuel_cons_change_twh <dbl> NA, NA, NA, NA, NA, NA, N…
## $ biofuel_cons_per_capita <dbl> NA, NA, NA, NA, NA, NA, N…
## $ biofuel_consumption <dbl> NA, NA, NA, NA, NA, NA, N…
## $ biofuel_elec_per_capita <dbl> NA, NA, NA, NA, NA, NA, N…
## $ biofuel_electricity <dbl> 5.87, 6.46, 6.62, 7.45, 8…
## $ biofuel_share_elec <dbl> 1.550, 1.596, 1.528, 1.62…
## $ biofuel_share_energy <dbl> NA, NA, NA, NA, NA, NA, N…
## $ carbon_intensity_elec <dbl> 569.557, 567.642, 570.212…
## $ coal_cons_change_pct <dbl> NA, NA, NA, NA, NA, NA, N…
## $ coal_cons_change_twh <dbl> NA, NA, NA, NA, NA, NA, N…
## $ coal_cons_per_capita <dbl> NA, NA, NA, NA, NA, NA, N…
## $ coal_consumption <dbl> NA, NA, NA, NA, NA, NA, N…
## $ coal_elec_per_capita <dbl> NA, NA, NA, NA, NA, NA, N…
## $ coal_electricity <dbl> 76.03, 86.26, 93.43, 102.…
## $ coal_prod_change_pct <dbl> NA, NA, NA, NA, NA, NA, N…
## $ coal_prod_change_twh <dbl> NA, NA, NA, NA, NA, NA, N…
## $ coal_prod_per_capita <dbl> NA, NA, NA, NA, NA, NA, N…
## $ coal_production <dbl> NA, NA, NA, NA, NA, NA, N…
## $ coal_share_elec <dbl> 20.081, 21.307, 21.568, 2…
## $ coal_share_energy <dbl> NA, NA, NA, NA, NA, NA, N…
## $ electricity_demand <dbl> 378.61, 404.85, 433.19, 4…
## $ electricity_generation <dbl> 378.61, 404.85, 433.19, 4…
## $ electricity_share_energy <dbl> NA, NA, NA, NA, NA, NA, N…
## $ energy_cons_change_pct <dbl> NA, NA, NA, NA, NA, NA, N…
## $ energy_cons_change_twh <dbl> NA, NA, NA, NA, NA, NA, N…
## $ energy_per_capita <dbl> NA, NA, NA, NA, NA, NA, N…
## $ energy_per_gdp <dbl> NA, NA, NA, NA, NA, NA, N…
## $ fossil_cons_change_pct <dbl> NA, NA, NA, NA, NA, NA, N…
## $ fossil_cons_change_twh <dbl> NA, NA, NA, NA, NA, NA, N…
## $ fossil_elec_per_capita <dbl> NA, NA, NA, NA, NA, NA, N…
## $ fossil_electricity <dbl> 305.36, 327.66, 356.67, 3…
## $ fossil_energy_per_capita <dbl> NA, NA, NA, NA, NA, NA, N…
## $ fossil_fuel_consumption <dbl> NA, NA, NA, NA, NA, NA, N…
## $ fossil_share_elec <dbl> 80.653, 80.934, 82.336, 8…
## $ fossil_share_energy <dbl> NA, NA, NA, NA, NA, NA, N…
## $ gas_cons_change_pct <dbl> NA, NA, NA, NA, NA, NA, N…
## $ gas_cons_change_twh <dbl> NA, NA, NA, NA, NA, NA, N…
## $ gas_consumption <dbl> NA, NA, NA, NA, NA, NA, N…
## $ gas_elec_per_capita <dbl> NA, NA, NA, NA, NA, NA, N…
## $ gas_electricity <dbl> 164.26, 190.41, 208.92, 2…
## $ gas_energy_per_capita <dbl> NA, NA, NA, NA, NA, NA, N…
## $ gas_prod_change_pct <dbl> NA, NA, NA, NA, NA, NA, N…
## $ gas_prod_change_twh <dbl> NA, NA, NA, NA, NA, NA, N…
## $ gas_prod_per_capita <dbl> NA, NA, NA, NA, NA, NA, N…
## $ gas_production <dbl> NA, NA, NA, NA, NA, NA, N…
## $ gas_share_elec <dbl> 43.385, 47.032, 48.228, 4…
## $ gas_share_energy <dbl> NA, NA, NA, NA, NA, NA, N…
## $ greenhouse_gas_emissions <dbl> 215.64, 229.81, 247.01, 2…
## $ hydro_cons_change_pct <dbl> NA, NA, NA, NA, NA, NA, N…
## $ hydro_cons_change_twh <dbl> NA, NA, NA, NA, NA, NA, N…
## $ hydro_consumption <dbl> NA, NA, NA, NA, NA, NA, N…
## $ hydro_elec_per_capita <dbl> NA, NA, NA, NA, NA, NA, N…
## $ hydro_electricity <dbl> 50.45, 54.33, 53.29, 53.2…
## $ hydro_energy_per_capita <dbl> NA, NA, NA, NA, NA, NA, N…
## $ hydro_share_elec <dbl> 13.325, 13.420, 12.302, 1…
## $ hydro_share_energy <dbl> NA, NA, NA, NA, NA, NA, N…
## $ low_carbon_cons_change_pct <dbl> NA, NA, NA, NA, NA, NA, N…
## $ low_carbon_cons_change_twh <dbl> NA, NA, NA, NA, NA, NA, N…
## $ low_carbon_consumption <dbl> NA, NA, NA, NA, NA, NA, N…
## $ low_carbon_elec_per_capita <dbl> NA, NA, NA, NA, NA, NA, N…
## $ low_carbon_electricity <dbl> 73.25, 77.19, 76.52, 76.4…
## $ low_carbon_energy_per_capita <dbl> NA, NA, NA, NA, NA, NA, N…
## $ low_carbon_share_elec <dbl> 19.347, 19.066, 17.664, 1…
## $ low_carbon_share_energy <dbl> NA, NA, NA, NA, NA, NA, N…
## $ net_elec_imports <dbl> NA, NA, NA, NA, NA, NA, N…
## $ net_elec_imports_share_demand <dbl> NA, NA, NA, NA, NA, NA, N…
## $ nuclear_cons_change_pct <dbl> NA, NA, NA, NA, NA, NA, N…
## $ nuclear_cons_change_twh <dbl> NA, NA, NA, NA, NA, NA, N…
## $ nuclear_consumption <dbl> NA, NA, NA, NA, NA, NA, N…
## $ nuclear_elec_per_capita <dbl> NA, NA, NA, NA, NA, NA, N…
## $ nuclear_electricity <dbl> 0, 0, 0, 0, 0, 0, 0, 0, 0…
## $ nuclear_energy_per_capita <dbl> NA, NA, NA, NA, NA, NA, N…
## $ nuclear_share_elec <dbl> 0, 0, 0, 0, 0, 0, 0, 0, 0…
## $ nuclear_share_energy <dbl> NA, NA, NA, NA, NA, NA, N…
## $ oil_cons_change_pct <dbl> NA, NA, NA, NA, NA, NA, N…
## $ oil_cons_change_twh <dbl> NA, NA, NA, NA, NA, NA, N…
## $ oil_consumption <dbl> NA, NA, NA, NA, NA, NA, N…
## $ oil_elec_per_capita <dbl> NA, NA, NA, NA, NA, NA, N…
## $ oil_electricity <dbl> 65.07, 50.99, 54.32, 53.3…
## $ oil_energy_per_capita <dbl> NA, NA, NA, NA, NA, NA, N…
## $ oil_prod_change_pct <dbl> NA, NA, NA, NA, NA, NA, N…
## $ oil_prod_change_twh <dbl> NA, NA, NA, NA, NA, NA, N…
## $ oil_prod_per_capita <dbl> NA, NA, NA, NA, NA, NA, N…
## $ oil_production <dbl> NA, NA, NA, NA, NA, NA, N…
## $ oil_share_elec <dbl> 17.187, 12.595, 12.540, 1…
## $ oil_share_energy <dbl> NA, NA, NA, NA, NA, NA, N…
## $ other_renewable_consumption <dbl> NA, NA, NA, NA, NA, NA, N…
## $ other_renewable_electricity <dbl> 22.80, 22.86, 23.23, 23.1…
## $ other_renewable_exc_biofuel_electricity <dbl> 16.93, 16.40, 16.61, 15.7…
## $ other_renewables_cons_change_pct <dbl> NA, NA, NA, NA, NA, NA, N…
## $ other_renewables_cons_change_twh <dbl> NA, NA, NA, NA, NA, NA, N…
## $ other_renewables_elec_per_capita <dbl> NA, NA, NA, NA, NA, NA, N…
## $ other_renewables_elec_per_capita_exc_biofuel <dbl> NA, NA, NA, NA, NA, NA, N…
## $ other_renewables_energy_per_capita <dbl> NA, NA, NA, NA, NA, NA, N…
## $ other_renewables_share_elec <dbl> 6.022, 5.647, 5.363, 5.06…
## $ other_renewables_share_elec_exc_biofuel <dbl> 4.472, 4.051, 3.834, 3.43…
## $ other_renewables_share_energy <dbl> NA, NA, NA, NA, NA, NA, N…
## $ per_capita_electricity <dbl> NA, NA, NA, NA, NA, NA, N…
## $ primary_energy_consumption <dbl> NA, NA, NA, NA, NA, NA, N…
## $ renewables_cons_change_pct <dbl> NA, NA, NA, NA, NA, NA, N…
## $ renewables_cons_change_twh <dbl> NA, NA, NA, NA, NA, NA, N…
## $ renewables_consumption <dbl> NA, NA, NA, NA, NA, NA, N…
## $ renewables_elec_per_capita <dbl> NA, NA, NA, NA, NA, NA, N…
## $ renewables_electricity <dbl> 73.25, 77.19, 76.52, 76.4…
## $ renewables_energy_per_capita <dbl> NA, NA, NA, NA, NA, NA, N…
## $ renewables_share_elec <dbl> 19.347, 19.066, 17.664, 1…
## $ renewables_share_energy <dbl> NA, NA, NA, NA, NA, NA, N…
## $ solar_cons_change_pct <dbl> NA, NA, NA, NA, NA, NA, N…
## $ solar_cons_change_twh <dbl> NA, NA, NA, NA, NA, NA, N…
## $ solar_consumption <dbl> NA, NA, NA, NA, NA, NA, N…
## $ solar_elec_per_capita <dbl> NA, NA, NA, NA, NA, NA, N…
## $ solar_electricity <dbl> 0.00, 0.00, 0.00, 0.00, 0…
## $ solar_energy_per_capita <dbl> NA, NA, NA, NA, NA, NA, N…
## $ solar_share_elec <dbl> 0.000, 0.000, 0.000, 0.00…
## $ solar_share_energy <dbl> NA, NA, NA, NA, NA, NA, N…
## $ wind_cons_change_pct <dbl> NA, NA, NA, NA, NA, NA, N…
## $ wind_cons_change_twh <dbl> NA, NA, NA, NA, NA, NA, N…
## $ wind_consumption <dbl> NA, NA, NA, NA, NA, NA, N…
## $ wind_elec_per_capita <dbl> NA, NA, NA, NA, NA, NA, N…
## $ wind_electricity <dbl> 0.00, 0.00, 0.00, 0.00, 0…
## $ wind_energy_per_capita <dbl> NA, NA, NA, NA, NA, NA, N…
## $ wind_share_elec <dbl> 0.000, 0.000, 0.000, 0.00…
## $ wind_share_energy <dbl> NA, NA, NA, NA, NA, NA, N…
energy_mix <- energy_data %>%
filter(year >= 1990 & year <= 2020) %>%
filter(!is.na(fossil_energy_per_capita), !is.na(nuclear_energy_per_capita), !is.na(renewables_energy_per_capita))%>%
filter(country %in% c("Germany", "France", "Poland", "Ireland")) %>%
select(year, country, fossil_energy_per_capita, nuclear_energy_per_capita, renewables_energy_per_capita) %>%
group_by(country)
print(energy_mix)
## # A tibble: 124 × 5
## # Groups: country [4]
## year country fossil_energy_per_capita nuclear_energy_per_capita
## <dbl> <chr> <dbl> <dbl>
## 1 1990 France 28242. 15798.
## 2 1991 France 30311. 16598.
## 3 1992 France 29664. 16888.
## 4 1993 France 28229. 18311.
## 5 1994 France 27299. 17848.
## 6 1995 France 28011. 18641.
## 7 1996 France 29142. 19566.
## 8 1997 France 28405. 19402.
## 9 1998 France 29980. 18955.
## 10 1999 France 29693. 19171.
## # ℹ 114 more rows
## # ℹ 1 more variable: renewables_energy_per_capita <dbl>
co2_per_gdp_capita_joint <- left_join(co2_per_capita_countries, co2_per_gdp_countries)
## Joining with `by = join_by(year, country)`
co2_per_gdp_capita_energy_joint <- left_join(co2_per_gdp_capita_joint, energy_mix)
## Joining with `by = join_by(year, country)`
variables_of_interest_joint <- left_join(co2_per_gdp_capita_energy_joint, policy_stringency_value)
## Joining with `by = join_by(year, country)`
variables_of_interest_joint
## # A tibble: 124 × 8
## # Groups: country [4]
## year country co2_per_capita co2_per_gdp fossil_energy_per_capita
## <dbl> <chr> <dbl> <dbl> <dbl>
## 1 1990 France 6.91 0.241 28242.
## 2 1991 France 7.30 0.253 30311.
## 3 1992 France 7.08 0.242 29664.
## 4 1993 France 6.71 0.232 28229.
## 5 1994 France 6.56 0.222 27299.
## 6 1995 France 6.63 0.221 28011.
## 7 1996 France 6.89 0.227 29142.
## 8 1997 France 6.74 0.217 28405.
## 9 1998 France 7.03 0.22 29980.
## 10 1999 France 6.97 0.211 29693.
## # ℹ 114 more rows
## # ℹ 3 more variables: nuclear_energy_per_capita <dbl>,
## # renewables_energy_per_capita <dbl>, stringency_value <dbl>
#Summary Table
policy_stringency_co2_90s <- variables_of_interest_joint %>%
filter(year >= 1990 & year <= 2000) %>%
filter(!is.na(co2_per_capita), !is.na(stringency_value)) %>%
select(year, country, co2_per_capita, stringency_value) %>%
group_by(country) %>%
summarise(
decade = paste0(min(year, na.rm = TRUE), "-", max(year, na.rm = TRUE)),
co2_per_capita_mean = mean(co2_per_capita, na.rm = TRUE),
co2_per_capita_sd = sd(co2_per_capita, na.rm = TRUE),
policy_stringency_mean = mean(stringency_value, na.rm = TRUE),
policy_stringency_sd = sd(stringency_value, na.rm = TRUE),
.groups = "drop"
)
print(policy_stringency_co2_90s)
## # A tibble: 4 × 6
## country decade co2_per_capita_mean co2_per_capita_sd policy_stringency_mean
## <chr> <chr> <dbl> <dbl> <dbl>
## 1 France 1990-2000 6.88 0.214 1.46
## 2 Germany 1990-2000 11.7 0.696 1.59
## 3 Ireland 1990-2000 10.2 0.867 0.727
## 4 Poland 1990-2000 9.34 0.528 0.725
## # ℹ 1 more variable: policy_stringency_sd <dbl>
policy_stringency_co2_00s <- variables_of_interest_joint %>%
filter(year >= 2001 & year <= 2010) %>%
filter(!is.na(co2_per_capita), !is.na(stringency_value)) %>%
select(year, country, co2_per_capita, stringency_value) %>%
group_by(country) %>%
summarise(
decade = paste0(min(year, na.rm = TRUE), "-", max(year, na.rm = TRUE)),
co2_per_capita_mean = mean(co2_per_capita, na.rm = TRUE),
co2_per_capita_sd = sd(co2_per_capita, na.rm = TRUE),
policy_stringency_mean = mean(stringency_value, na.rm = TRUE),
policy_stringency_sd = sd(stringency_value, na.rm = TRUE),
.groups = "drop"
)
print(policy_stringency_co2_00s)
## # A tibble: 4 × 6
## country decade co2_per_capita_mean co2_per_capita_sd policy_stringency_mean
## <chr> <chr> <dbl> <dbl> <dbl>
## 1 France 2001-2010 6.48 0.365 2.85
## 2 Germany 2001-2010 10.6 0.407 2.75
## 3 Ireland 2001-2010 10.9 1.02 2.12
## 4 Poland 2001-2010 8.49 0.284 2.02
## # ℹ 1 more variable: policy_stringency_sd <dbl>
policy_stringency_co2_10s <- variables_of_interest_joint %>%
filter(year >= 2011 & year <= 2020) %>%
filter(!is.na(co2_per_capita), !is.na(stringency_value)) %>%
select(year, country, co2_per_capita, stringency_value) %>%
group_by(country) %>%
summarise(
decade = paste0(min(year, na.rm = TRUE), "-", max(year, na.rm = TRUE)),
co2_per_capita_mean = mean(co2_per_capita, na.rm = TRUE),
co2_per_capita_sd = sd(co2_per_capita, na.rm = TRUE),
policy_stringency_mean = mean(stringency_value, na.rm = TRUE),
policy_stringency_sd = sd(stringency_value, na.rm = TRUE),
.groups = "drop"
)
print(policy_stringency_co2_10s)
## # A tibble: 4 × 6
## country decade co2_per_capita_mean co2_per_capita_sd policy_stringency_mean
## <chr> <chr> <dbl> <dbl> <dbl>
## 1 France 2011-2020 5.11 0.408 4.23
## 2 Germany 2011-2020 9.42 0.774 3.17
## 3 Ireland 2011-2020 8.01 0.423 2.67
## 4 Poland 2011-2020 8.42 0.302 3.02
## # ℹ 1 more variable: policy_stringency_sd <dbl>
merged_policy_stringency_co2 <- bind_rows(
policy_stringency_co2_90s,
policy_stringency_co2_00s,
policy_stringency_co2_10s
)
merged_policy_stringency_co2 <- merged_policy_stringency_co2 %>%
arrange(country, decade)
print(merged_policy_stringency_co2)
## # A tibble: 12 × 6
## country decade co2_per_capita_mean co2_per_capita_sd policy_stringency_mean
## <chr> <chr> <dbl> <dbl> <dbl>
## 1 France 1990-20… 6.88 0.214 1.46
## 2 France 2001-20… 6.48 0.365 2.85
## 3 France 2011-20… 5.11 0.408 4.23
## 4 Germany 1990-20… 11.7 0.696 1.59
## 5 Germany 2001-20… 10.6 0.407 2.75
## 6 Germany 2011-20… 9.42 0.774 3.17
## 7 Ireland 1990-20… 10.2 0.867 0.727
## 8 Ireland 2001-20… 10.9 1.02 2.12
## 9 Ireland 2011-20… 8.01 0.423 2.67
## 10 Poland 1990-20… 9.34 0.528 0.725
## 11 Poland 2001-20… 8.49 0.284 2.02
## 12 Poland 2011-20… 8.42 0.302 3.02
## # ℹ 1 more variable: policy_stringency_sd <dbl>
final_table <- merged_policy_stringency_co2 %>%
mutate(
co2_combined = sprintf("%.2f (%.2f)", co2_per_capita_mean, co2_per_capita_sd),
policy_combined = sprintf("%.2f (%.2f)", policy_stringency_mean, policy_stringency_sd)
) %>%
select(-ends_with("_mean"), -ends_with("_sd")) %>%
pivot_wider(
names_from = decade,
values_from = c(co2_combined, policy_combined),
names_glue = "{decade} {.value}"
) %>%
gt() %>%
cols_label(
country = "Country",
`1990-2000 co2_combined` = "1990-2000 CO2 per Capita (Mean/SD)",
`1990-2000 policy_combined` = "1990-2000 Policy Stringency (Mean/SD)",
`2001-2010 co2_combined` = "2001-2010 CO2 per Capita (Mean/SD)",
`2001-2010 policy_combined` = "2001-2010 Policy Stringency (Mean/SD)",
`2011-2020 co2_combined` = "2011-2020 CO2 per Capita (Mean/SD)",
`2011-2020 policy_combined` = "2011-2020 Policy Stringency (Mean/SD)"
) %>%
tab_style(
style = cell_text(weight = "bold"),
locations = cells_column_labels()
) %>%
tab_header(
title = md("**CO2 Emissions per capita and Environmental Policy Stringency since 1990**"),
subtitle = md("calculation of Mean and Standard Deviation (SD) over decades in OECD member countries")
) %>%
tab_source_note(
source_note = md(
"Emissions of carbon dioxide (CO2), excluding land-use change, measured in tonnes per person. \nAll environmental policy stringency measured on a 0-6 scale. 0 means no policy in place, and higher numbers mean stricter policies, with 6 being the most stringent."
)
) %>%
tab_style(
style = cell_text(size = px(14)),
locations = cells_title(groups = "subtitle")
)
final_table
| CO2 Emissions per capita and Environmental Policy Stringency since 1990 | ||||||
| calculation of Mean and Standard Deviation (SD) over decades in OECD member countries | ||||||
| Country | 1990-2000 CO2 per Capita (Mean/SD) | 2001-2010 CO2 per Capita (Mean/SD) | 2011-2020 CO2 per Capita (Mean/SD) | 1990-2000 Policy Stringency (Mean/SD) | 2001-2010 Policy Stringency (Mean/SD) | 2011-2020 Policy Stringency (Mean/SD) |
|---|---|---|---|---|---|---|
| France | 6.88 (0.21) | 6.48 (0.37) | 5.11 (0.41) | 1.46 (0.13) | 2.85 (0.71) | 4.23 (0.37) |
| Germany | 11.71 (0.70) | 10.61 (0.41) | 9.42 (0.77) | 1.59 (0.11) | 2.75 (0.40) | 3.17 (0.14) |
| Ireland | 10.22 (0.87) | 10.95 (1.02) | 8.01 (0.42) | 0.73 (0.26) | 2.12 (0.56) | 2.67 (0.19) |
| Poland | 9.34 (0.53) | 8.49 (0.28) | 8.42 (0.30) | 0.72 (0.17) | 2.02 (0.67) | 3.02 (0.24) |
| Emissions of carbon dioxide (CO2), excluding land-use change, measured in tonnes per person. All environmental policy stringency measured on a 0-6 scale. 0 means no policy in place, and higher numbers mean stricter policies, with 6 being the most stringent. | ||||||
#Graph
co2_policy_stringency_clean <- variables_of_interest_joint %>%
filter(year >= 1990 & year <= 2022) %>%
filter(!is.na(co2_per_capita), !is.na(stringency_value))%>%
filter(country %in% c("Germany", "Poland", "France", "Finland", "Ireland")) %>%
select(year, country, co2_per_capita, stringency_value) %>%
group_by(country)
print(co2_policy_stringency_clean)
## # A tibble: 124 × 4
## # Groups: country [4]
## year country co2_per_capita stringency_value
## <dbl> <chr> <dbl> <dbl>
## 1 1990 France 6.91 1.44
## 2 1991 France 7.30 1.33
## 3 1992 France 7.08 1.33
## 4 1993 France 6.71 1.33
## 5 1994 France 6.56 1.39
## 6 1995 France 6.63 1.39
## 7 1996 France 6.89 1.47
## 8 1997 France 6.74 1.47
## 9 1998 France 7.03 1.47
## 10 1999 France 6.97 1.64
## # ℹ 114 more rows
co2_policy_long <- co2_policy_stringency_clean %>%
select(
"CO2 per Capita" = co2_per_capita,
"Policy Stringency" = stringency_value,
year,
country
) %>%
pivot_longer(
cols = c("CO2 per Capita", "Policy Stringency"),
names_to = "metric",
values_to = "value"
)
ggplot(
co2_policy_long,
aes(
x = year,
y = value,
color = country
)
) +
geom_line(linewidth = 1.2) +
scale_color_brewer(palette = "Set1") +
facet_wrap(~metric,
ncol = 1,
scales = "free_y",
strip.position = "top") +
scale_x_continuous(
breaks = seq(1990, 2020, by = 5),
limits = c(1990, 2020)
) +
theme(
strip.text = element_text(size = 12, face = "bold"),
strip.placement = "outside",
strip.background = element_blank(),
panel.background = element_blank(),
panel.grid = element_blank(),
axis.line = element_line(),
plot.title = element_text(face = "bold", size = 14, hjust = 0.5),
plot.subtitle = element_text(size = 12, hjust = 0.5),
legend.position = "right",
axis.title.y = element_text(size = 10.5, hjust = 0.3),
legend.title = element_text(face = "bold", size = 12),
plot.caption = element_text(face = "italic", hjust = 0)
) +
labs(
title = "Comparison between CO2 emissions and environmental policy stringency",
subtitle = "in OECD countries (1990-2020)",
x = "Year",
y = "All environmental policy Tonnes per person",
color = "Country",
caption = paste("Emissions of carbon dioxide (CO2), excluding land-use change, measured in tonnes per person. \nAll environmental policy stringency measured on a 0-6 scale. \n0 means no policy in place, and higher numbers mean stricter policies, with 6 being the most stringent.")
)
#Descriptive Tables
key_vars_summary <- GHG_emissions %>%
filter(country %in% c("Poland", "Germany", "United States", "Canada")) %>%
filter(year >= 1990 & year <= 2020) %>%
filter(!is.na(co2) & !is.na(gdp)) %>%
group_by(country) %>%
summarise(
Years = paste0(min(year, na.rm = TRUE), "-", max(year, na.rm = TRUE)),
CO2_mean = mean(co2, na.rm = TRUE),
CO2_median = median(co2, na.rm = TRUE),
CO2_range = paste(round(min(co2, na.rm = TRUE), 2), "-", round(max(co2, na.rm = TRUE), 2)),
GDP_per_capita_mean = mean(gdp / population, na.rm = TRUE),
GDP_per_capita_median = median(gdp / population, na.rm = TRUE),
GDP_per_capita_range = paste(round(min(gdp / population, na.rm = TRUE), 2), "-", round(max(gdp / population, na.rm = TRUE), 2)),
.groups = "drop"
)
print(key_vars_summary)
## # A tibble: 4 × 8
## country Years CO2_mean CO2_median CO2_range GDP_per_capita_mean
## <chr> <chr> <dbl> <dbl> <chr> <dbl>
## 1 Canada 1990-2020 542. 563. 449.76 - 591.… 38215.
## 2 Germany 1990-2020 868. 877. 648.36 - 1054… 36607.
## 3 Poland 1990-2020 335. 330. 302.43 - 377.… 16970.
## 4 United States 1990-2020 5572. 5529. 4714.63 - 613… 46640.
## # ℹ 2 more variables: GDP_per_capita_median <dbl>, GDP_per_capita_range <chr>
key_vars_table <- key_vars_summary %>%
gt() %>%
cols_label(
country = "Country",
Years = "Year Range",
CO2_mean = "Mean CO₂ (Mt)",
CO2_median = "Median CO₂ (Mt)",
CO2_range = "CO₂ Range (Mt)",
GDP_per_capita_mean = "Mean GDP per capita (int-$)",
GDP_per_capita_median = "Median GDP per capita (int-$)",
GDP_per_capita_range = "GDP per capita Range (int-$)"
) %>%
fmt_number(columns = c(CO2_mean, CO2_median, GDP_per_capita_mean, GDP_per_capita_median), decimals = 2) %>%
tab_header(
title = md("**Descriptive Statistics for Key Variables**"),
subtitle = md("CO₂ Emissions and GDP per Capita")
) %>%
tab_source_note(
source_note = md("Data year rage 1950–2022. CO₂ measured in million tonnes (Mt); GDP per capita in international-$.")
) %>%
tab_style(
style = cell_text(weight = "bold"),
locations = cells_column_labels()
)
key_vars_table
| Descriptive Statistics for Key Variables | |||||||
| CO₂ Emissions and GDP per Capita | |||||||
| Country | Year Range | Mean CO₂ (Mt) | Median CO₂ (Mt) | CO₂ Range (Mt) | Mean GDP per capita (int-$) | Median GDP per capita (int-$) | GDP per capita Range (int-$) |
|---|---|---|---|---|---|---|---|
| Canada | 1990-2020 | 542.19 | 563.32 | 449.76 - 591.89 | 38,215.42 | 40,221.23 | 29113.69 - 45228.31 |
| Germany | 1990-2020 | 867.62 | 876.57 | 648.36 - 1054.8 | 36,607.22 | 35,899.80 | 25286.65 - 46510.66 |
| Poland | 1990-2020 | 335.19 | 329.57 | 302.43 - 377.29 | 16,969.84 | 15,631.96 | 7634.77 - 29331.74 |
| United States | 1990-2020 | 5,571.99 | 5,528.68 | 4714.63 - 6132.18 | 46,640.32 | 48,495.82 | 35967.7 - 54887.79 |
| Data year rage 1950–2022. CO₂ measured in million tonnes (Mt); GDP per capita in international-$. | |||||||
energy_mix_data <- energy_data %>%
filter(year >= 1990 & year <= 2020) %>%
filter(!is.na(fossil_energy_per_capita), !is.na(nuclear_energy_per_capita), !is.na(renewables_energy_per_capita))%>%
filter(country %in% c("Germany", "France", "Poland", "Ireland")) %>%
group_by(country) %>%
summarise(
Years = paste0(min(year, na.rm = TRUE), "-", max(year, na.rm = TRUE)),
fossil_mean = mean(fossil_energy_per_capita, na.rm = TRUE),
fossil_median = median(fossil_energy_per_capita, na.rm = TRUE),
fossil_range = paste(round(min(fossil_energy_per_capita, na.rm = TRUE), 2), "-", round(max(fossil_energy_per_capita, na.rm = TRUE), 2)),
nuclear_mean = mean(nuclear_energy_per_capita, na.rm = TRUE),
nuclear_median = median(nuclear_energy_per_capita, na.rm = TRUE),
nuclear_range = paste(round(min(nuclear_energy_per_capita, na.rm = TRUE), 2), "-", round(max(nuclear_energy_per_capita, na.rm = TRUE), 2)),
renewables_mean = mean(renewables_energy_per_capita, na.rm = TRUE),
renewables_median = median(renewables_energy_per_capita, na.rm = TRUE),
renewables_range = paste(round(min(renewables_energy_per_capita, na.rm = TRUE), 2), "-", round(max(renewables_energy_per_capita, na.rm = TRUE), 2)),
.groups = "drop"
)
print(energy_mix_data)
## # A tibble: 4 × 11
## country Years fossil_mean fossil_median fossil_range nuclear_mean
## <chr> <chr> <dbl> <dbl> <chr> <dbl>
## 1 France 1990-2020 26458. 28011. 18458.41 - 30310.66 18250.
## 2 Germany 1990-2020 40061. 41398. 30651.35 - 46665.72 4566.
## 3 Ireland 1990-2020 37627. 36480. 27938.45 - 47042.2 0
## 4 Poland 1990-2020 28244. 28225. 25652.03 - 31682.33 0
## # ℹ 5 more variables: nuclear_median <dbl>, nuclear_range <chr>,
## # renewables_mean <dbl>, renewables_median <dbl>, renewables_range <chr>
energy_mix_table <- energy_mix_data %>%
gt() %>%
cols_label(
country = "Country",
Years = "Year Range",
fossil_mean = "Fossil Fuel Energy (Mean)",
fossil_median = "Fossil Fuel Energy (Median)",
fossil_range = "Fossil Fuel Energy Range",
nuclear_mean = "Nuclear Energy (Mean)",
nuclear_median = "Nuclear Energy (Median)",
nuclear_range = "Nuclear Energy Range",
renewables_mean = "Renewable Energy (Mean)",
renewables_median = "Renewable Energy (Median)",
renewables_range = "Renewable Energy Range",
) %>%
fmt_number(columns = c(fossil_mean, fossil_median, nuclear_mean, nuclear_median, renewables_mean, renewables_median), decimals = 2) %>%
tab_header(
title = md("**Descriptive Statistics for Energy consumption**"),
subtitle = md("Measured in kilowatt-hours per person")
) %>%
tab_source_note(
source_note = md("Poland and Ireland did not adopt nuclear energy")
) %>%
tab_style(
style = cell_text(weight = "bold"),
locations = cells_column_labels()
)
energy_mix_table
| Descriptive Statistics for Energy consumption | ||||||||||
| Measured in kilowatt-hours per person | ||||||||||
| Country | Year Range | Fossil Fuel Energy (Mean) | Fossil Fuel Energy (Median) | Fossil Fuel Energy Range | Nuclear Energy (Mean) | Nuclear Energy (Median) | Nuclear Energy Range | Renewable Energy (Mean) | Renewable Energy (Median) | Renewable Energy Range |
|---|---|---|---|---|---|---|---|---|---|---|
| France | 1990-2020 | 26,458.42 | 28,010.88 | 18458.41 - 30310.66 | 18,250.36 | 18,311.49 | 13829.41 - 20620.83 | 3,845.85 | 3,706.96 | 2795.18 - 5571.42 |
| Germany | 1990-2020 | 40,060.82 | 41,398.22 | 30651.35 - 46665.72 | 4,566.29 | 5,304.41 | 1947.16 - 5934.82 | 3,435.38 | 2,541.42 | 651.49 - 8730.23 |
| Ireland | 1990-2020 | 37,626.88 | 36,479.72 | 27938.45 - 47042.2 | 0.00 | 0.00 | 0 - 0 | 2,404.56 | 1,314.38 | 591.34 - 7660.49 |
| Poland | 1990-2020 | 28,243.93 | 28,224.72 | 25652.03 - 31682.33 | 0.00 | 0.00 | 0 - 0 | 780.95 | 312.64 | 114.69 - 2360.37 |
| Poland and Ireland did not adopt nuclear energy | ||||||||||
policy_stringency_data <- variables_of_interest_joint %>%
summarise(
Years = paste0(min(year, na.rm = TRUE), "-", max(year, na.rm = TRUE)),
CO2_mean = mean(co2, na.rm = TRUE),
CO2_median = median(co2, na.rm = TRUE),
CO2_range = paste(round(min(co2, na.rm = TRUE), 2), "-", round(max(co2, na.rm = TRUE), 2)),
stringency_mean = mean(stringency_value, na.rm = TRUE),
stringency_median = median(stringency_value, na.rm = TRUE),
stringency_range = paste(round(min(stringency_value, na.rm = TRUE), 2), "-", round(max(stringency_value, na.rm = TRUE), 2)),
.groups = "drop"
)
print(policy_stringency_data)
## # A tibble: 4 × 8
## country Years CO2_mean CO2_median CO2_range stringency_mean stringency_median
## <chr> <chr> <dbl> <dbl> <chr> <dbl> <dbl>
## 1 France 1990-… 337. 335. 313.18 -… 2.80 2.86
## 2 Germany 1990-… 337. 335. 313.18 -… 2.48 2.78
## 3 Ireland 1990-… 337. 335. 313.18 -… 1.80 2.08
## 4 Poland 1990-… 337. 335. 313.18 -… 1.88 2.08
## # ℹ 1 more variable: stringency_range <chr>
policy_stringency_table <- policy_stringency_data %>%
gt() %>%
cols_label(
country = "Country",
Years = "Year Range",
CO2_mean = "Mean CO₂ (Mt)",
CO2_median = "Median CO₂ (Mt)",
CO2_range = "CO₂ Range (Mt)",
stringency_mean = "Mean policy stringency (0-6)",
stringency_median = "Median policy stringency (0-6)",
stringency_range = "policy stringency Range (0-6)"
) %>%
fmt_number(columns = c(CO2_mean, CO2_median, stringency_mean, stringency_median), decimals = 2) %>%
tab_header(
title = md("**Descriptive Statistics for Environmental Policy Stringency**"),
subtitle = md("CO₂ Emissions and Policy Stringency")
) %>%
tab_source_note(
source_note = md("Emissions of carbon dioxide (CO2), excluding land-use change, measured in tonnes per person. \nAll environmental policy stringency measured on a 0-6 scale. 0 means no policy in place, and higher numbers mean stricter policies, with 6 being the most stringent.")
) %>%
tab_style(
style = cell_text(weight = "bold"),
locations = cells_column_labels()
)
policy_stringency_table
| Descriptive Statistics for Environmental Policy Stringency | |||||||
| CO₂ Emissions and Policy Stringency | |||||||
| Country | Year Range | Mean CO₂ (Mt) | Median CO₂ (Mt) | CO₂ Range (Mt) | Mean policy stringency (0-6) | Median policy stringency (0-6) | policy stringency Range (0-6) |
|---|---|---|---|---|---|---|---|
| France | 1990-2020 | 337.05 | 335.17 | 313.18 - 366.84 | 2.80 | 2.86 | 1.33 - 4.89 |
| Germany | 1990-2020 | 337.05 | 335.17 | 313.18 - 366.84 | 2.48 | 2.78 | 1.44 - 3.47 |
| Ireland | 1990-2020 | 337.05 | 335.17 | 313.18 - 366.84 | 1.80 | 2.08 | 0.47 - 3 |
| Poland | 1990-2020 | 337.05 | 335.17 | 313.18 - 366.84 | 1.88 | 2.08 | 0.53 - 3.47 |
| Emissions of carbon dioxide (CO2), excluding land-use change, measured in tonnes per person. All environmental policy stringency measured on a 0-6 scale. 0 means no policy in place, and higher numbers mean stricter policies, with 6 being the most stringent. | |||||||
#Adittional Pattern Exploration
##GDP
co2_per_gdp_countries <- GHG_emissions %>%
filter(year >= 1990 & year <= 2022) %>%
filter(!is.na(co2_per_gdp))%>%
filter(country %in% c("Poland", "Germany", "Ireland", "France")) %>%
select(year, country, co2_per_gdp) %>%
group_by(country)
print(co2_per_gdp_countries)
## # A tibble: 132 × 3
## # Groups: country [4]
## year country co2_per_gdp
## <dbl> <chr> <dbl>
## 1 1990 France 0.241
## 2 1991 France 0.253
## 3 1992 France 0.242
## 4 1993 France 0.232
## 5 1994 France 0.222
## 6 1995 France 0.221
## 7 1996 France 0.227
## 8 1997 France 0.217
## 9 1998 France 0.22
## 10 1999 France 0.211
## # ℹ 122 more rows
ggplot(
co2_per_gdp_countries,
aes(x = year, y = co2_per_gdp,
color = country, fill = country)
) +
geom_line(linewidth = 1.2) +
scale_color_brewer(palette = "Set1") +
theme_minimal() +
theme(
panel.grid = element_blank(),
plot.title = element_text(face = "bold", size = 14, hjust = 0.5),
plot.subtitle = element_text(size = 12, hjust = 0.5),
legend.position = "right",
legend.title = element_text(face = "bold", size = 12),
axis.title.y = element_text(size = 8, hjust = 0.5),
plot.caption = element_text(face = "italic", hjust = 0)
) +
labs(
title = "CO2 emissions Per GDP over the years",
subtitle = "in OECD Countries",
x = "Year",
y = "CO2 per GDP, measured in \nkilograms per dollar of GDP",
color = "Country",
fill = "Country",
caption = paste("Hannah Ritchie, Pablo Rosado and Max Roser (2023) \n“CO2 and Greenhouse Gas Emissions” Published online at OurWorldinData.org.")
) +
scale_y_continuous(
breaks = seq(0, max(co2_per_gdp_countries$co2_per_gdp, na.rm = TRUE), by = 0.2)
) +
scale_x_continuous(
breaks = seq(0, max(co2_per_gdp_countries$year, na.rm = TRUE), by = 10)
)
##Energy mix
co2_energy_mix_merged <- left_join(co2_per_capita_countries, energy_mix)
## Joining with `by = join_by(year, country)`
print(co2_energy_mix_merged)
## # A tibble: 124 × 6
## # Groups: country [4]
## year country co2_per_capita fossil_energy_per_capita nuclear_energy_per_ca…¹
## <dbl> <chr> <dbl> <dbl> <dbl>
## 1 1990 France 6.91 28242. 15798.
## 2 1991 France 7.30 30311. 16598.
## 3 1992 France 7.08 29664. 16888.
## 4 1993 France 6.71 28229. 18311.
## 5 1994 France 6.56 27299. 17848.
## 6 1995 France 6.63 28011. 18641.
## 7 1996 France 6.89 29142. 19566.
## 8 1997 France 6.74 28405. 19402.
## 9 1998 France 7.03 29980. 18955.
## 10 1999 France 6.97 29693. 19171.
## # ℹ 114 more rows
## # ℹ abbreviated name: ¹nuclear_energy_per_capita
## # ℹ 1 more variable: renewables_energy_per_capita <dbl>
###France
energy_mix_france <- co2_energy_mix_merged %>%
filter(year >= 1990 & year <= 2020) %>%
filter(!is.na(fossil_energy_per_capita), !is.na(nuclear_energy_per_capita), !is.na(renewables_energy_per_capita))%>%
filter(country %in% c("France")) %>%
select(year, country, co2_per_capita, fossil_energy_per_capita, nuclear_energy_per_capita, renewables_energy_per_capita) %>%
group_by(country)
print(energy_mix_france)
## # A tibble: 31 × 6
## # Groups: country [1]
## year country co2_per_capita fossil_energy_per_capita nuclear_energy_per_ca…¹
## <dbl> <chr> <dbl> <dbl> <dbl>
## 1 1990 France 6.91 28242. 15798.
## 2 1991 France 7.30 30311. 16598.
## 3 1992 France 7.08 29664. 16888.
## 4 1993 France 6.71 28229. 18311.
## 5 1994 France 6.56 27299. 17848.
## 6 1995 France 6.63 28011. 18641.
## 7 1996 France 6.89 29142. 19566.
## 8 1997 France 6.74 28405. 19402.
## 9 1998 France 7.03 29980. 18955.
## 10 1999 France 6.97 29693. 19171.
## # ℹ 21 more rows
## # ℹ abbreviated name: ¹nuclear_energy_per_capita
## # ℹ 1 more variable: renewables_energy_per_capita <dbl>
energy_mix_france_long <- energy_mix_france %>%
pivot_longer(
cols = c(fossil_energy_per_capita, nuclear_energy_per_capita, renewables_energy_per_capita),
names_to = "energy_type",
values_to = "kwh_per_capita"
) %>%
mutate(energy_type = case_when(
energy_type == "fossil_energy_per_capita" ~ "Fossil",
energy_type == "nuclear_energy_per_capita" ~ "Nuclear",
energy_type == "renewables_energy_per_capita" ~ "Renewables"
))
combined_data <- energy_mix_france_long %>%
mutate(metric = "Energy Consumption (kWh/person)") %>%
rename(value = kwh_per_capita) %>%
bind_rows(
energy_mix_france %>%
mutate(
metric = "CO2 Emissions (tonnes/person)",
energy_type = "CO2"
) %>%
select(year, country, metric, energy_type, value = co2_per_capita)
)
ggplot(combined_data, aes(x = year, y = value, color = energy_type)) +
geom_line(linewidth = 1.2) +
scale_color_manual(
name = "Metric",
values = c("Fossil" = "#E41A1C",
"Nuclear" = "#377EB8",
"Renewables" = "#4DAF4A",
"CO2" = "black")
) +
facet_wrap(
~metric,
ncol = 1,
scales = "free_y",
strip.position = "top"
) +
scale_x_continuous(
breaks = seq(1990, 2020, by = 5),
limits = c(1990, 2020)
) +
theme(
strip.text = element_text(size = 12, face = "bold"),
strip.placement = "outside",
strip.background = element_blank(),
panel.background = element_blank(),
panel.grid = element_blank(),
axis.line = element_line(),
legend.position = "right",
legend.title = element_text(face = "bold", size = 12),
axis.title.y = element_text(size = 10, hjust = 0.5),
plot.title = element_text(face = "bold", size = 14, hjust = 0.5),
plot.subtitle = element_text(size = 12, hjust = 0.5)
) +
labs(
title = "France's Energy Mix and CO2 Emissions",
subtitle = "1990-2020",
x = "Year",
y = NULL,
caption = "Data: Our World in Data (2023)\nEnergy: kWh/person | CO2: tonnes/person"
)
###Germany
energy_mix_germany <- co2_energy_mix_merged %>%
filter(year >= 1990 & year <= 2020) %>%
filter(!is.na(fossil_energy_per_capita), !is.na(nuclear_energy_per_capita), !is.na(renewables_energy_per_capita))%>%
filter(country %in% c("Germany")) %>%
select(year, country, co2_per_capita, fossil_energy_per_capita, nuclear_energy_per_capita, renewables_energy_per_capita) %>%
group_by(country)
print(energy_mix_germany)
## # A tibble: 31 × 6
## # Groups: country [1]
## year country co2_per_capita fossil_energy_per_capita nuclear_energy_per_ca…¹
## <dbl> <chr> <dbl> <dbl> <dbl>
## 1 1990 Germany 13.2 46666. 5452.
## 2 1991 Germany 12.7 45367. 5241.
## 3 1992 Germany 12.0 43610. 5618.
## 4 1993 Germany 11.8 43349. 5406.
## 5 1994 Germany 11.5 42733. 5304.
## 6 1995 Germany 11.5 42681. 5390.
## 7 1996 Germany 11.7 44012. 5641.
## 8 1997 Germany 11.3 42939. 5935.
## 9 1998 Germany 11.3 42710. 5625.
## 10 1999 Germany 11.0 41601. 5915.
## # ℹ 21 more rows
## # ℹ abbreviated name: ¹nuclear_energy_per_capita
## # ℹ 1 more variable: renewables_energy_per_capita <dbl>
energy_mix_germany_long <- energy_mix_germany %>%
pivot_longer(
cols = c(fossil_energy_per_capita, nuclear_energy_per_capita, renewables_energy_per_capita),
names_to = "energy_type",
values_to = "kwh_per_capita"
) %>%
mutate(energy_type = case_when(
energy_type == "fossil_energy_per_capita" ~ "Fossil",
energy_type == "nuclear_energy_per_capita" ~ "Nuclear",
energy_type == "renewables_energy_per_capita" ~ "Renewables"
))
combined_data_germany <- energy_mix_germany_long %>%
mutate(metric = "Energy Consumption (kWh/person)") %>%
rename(value = kwh_per_capita) %>%
bind_rows(
energy_mix_germany %>%
mutate(
metric = "CO2 Emissions (tonnes/person)",
energy_type = "CO2"
) %>%
select(year, country, metric, energy_type, value = co2_per_capita)
)
ggplot(combined_data_germany, aes(x = year, y = value, color = energy_type)) +
geom_line(linewidth = 1.2) +
scale_color_manual(
name = "Metric",
values = c("Fossil" = "#E41A1C",
"Nuclear" = "#377EB8",
"Renewables" = "#4DAF4A",
"CO2" = "black")
) +
facet_wrap(
~metric,
ncol = 1,
scales = "free_y",
strip.position = "top"
) +
scale_x_continuous(
breaks = seq(1990, 2020, by = 5),
limits = c(1990, 2020)
) +
theme(
strip.text = element_text(size = 12, face = "bold"),
strip.placement = "outside",
strip.background = element_blank(),
panel.background = element_blank(),
panel.grid = element_blank(),
axis.line = element_line(),
legend.position = "right",
legend.title = element_text(face = "bold", size = 12),
axis.title.y = element_text(size = 10, hjust = 0.5),
plot.title = element_text(face = "bold", size = 14, hjust = 0.5),
plot.subtitle = element_text(size = 12, hjust = 0.5)
) +
labs(
title = "Germany's Energy Mix and CO2 Emissions",
subtitle = "1990-2020",
x = "Year",
y = NULL,
caption = "Data: Our World in Data (2023)\nEnergy: kWh/person | CO2: tonnes/person"
)
###Ireland
energy_mix_ireland <- co2_energy_mix_merged %>%
filter(year >= 1990 & year <= 2020) %>%
filter(!is.na(fossil_energy_per_capita), !is.na(nuclear_energy_per_capita), !is.na(renewables_energy_per_capita))%>%
filter(country %in% c("Ireland")) %>%
select(year, country, co2_per_capita, fossil_energy_per_capita, nuclear_energy_per_capita, renewables_energy_per_capita) %>%
group_by(country)
print(energy_mix_ireland)
## # A tibble: 31 × 6
## # Groups: country [1]
## year country co2_per_capita fossil_energy_per_capita nuclear_energy_per_ca…¹
## <dbl> <chr> <dbl> <dbl> <dbl>
## 1 1990 Ireland 9.38 33232. 0
## 2 1991 Ireland 9.53 34312. 0
## 3 1992 Ireland 9.41 34177. 0
## 4 1993 Ireland 9.43 34780. 0
## 5 1994 Ireland 9.70 36006. 0
## 6 1995 Ireland 9.93 36727. 0
## 7 1996 Ireland 10.3 38476. 0
## 8 1997 Ireland 10.6 39372. 0
## 9 1998 Ireland 11.0 41680. 0
## 10 1999 Ireland 11.3 43601. 0
## # ℹ 21 more rows
## # ℹ abbreviated name: ¹nuclear_energy_per_capita
## # ℹ 1 more variable: renewables_energy_per_capita <dbl>
energy_mix_ireland_long <- energy_mix_ireland %>%
pivot_longer(
cols = c(fossil_energy_per_capita, nuclear_energy_per_capita, renewables_energy_per_capita),
names_to = "energy_type",
values_to = "kwh_per_capita"
) %>%
mutate(energy_type = case_when(
energy_type == "fossil_energy_per_capita" ~ "Fossil",
energy_type == "nuclear_energy_per_capita" ~ "Nuclear",
energy_type == "renewables_energy_per_capita" ~ "Renewables"
))
combined_data_ireland <- energy_mix_ireland_long %>%
mutate(metric = "Energy Consumption (kWh/person)") %>%
rename(value = kwh_per_capita) %>%
bind_rows(
energy_mix_ireland %>%
mutate(
metric = "CO2 Emissions (tonnes/person)",
energy_type = "CO2"
) %>%
select(year, country, metric, energy_type, value = co2_per_capita)
)
ggplot(combined_data_ireland, aes(x = year, y = value, color = energy_type)) +
geom_line(linewidth = 1.2) +
scale_color_manual(
name = "Metric",
values = c("Fossil" = "#E41A1C",
"Nuclear" = "#377EB8",
"Renewables" = "#4DAF4A",
"CO2" = "black")
) +
facet_wrap(
~metric,
ncol = 1,
scales = "free_y",
strip.position = "top"
) +
scale_x_continuous(
breaks = seq(1990, 2020, by = 5),
limits = c(1990, 2020)
) +
theme(
strip.text = element_text(size = 12, face = "bold"),
strip.placement = "outside",
strip.background = element_blank(),
panel.background = element_blank(),
panel.grid = element_blank(),
axis.line = element_line(),
legend.position = "right",
legend.title = element_text(face = "bold", size = 12),
axis.title.y = element_text(size = 10, hjust = 0.5),
plot.title = element_text(face = "bold", size = 14, hjust = 0.5),
plot.subtitle = element_text(size = 12, hjust = 0.5)
) +
labs(
title = "Ireland's Energy Mix and CO2 Emissions",
subtitle = "1990-2020",
x = "Year",
y = NULL,
caption = "Data: Our World in Data (2023)\nEnergy: kWh/person | CO2: tonnes/person"
)
###Poland
energy_mix_poland <- co2_energy_mix_merged %>%
filter(year >= 1990 & year <= 2020) %>%
filter(!is.na(fossil_energy_per_capita), !is.na(nuclear_energy_per_capita), !is.na(renewables_energy_per_capita))%>%
filter(country %in% c("Poland")) %>%
select(year, country, co2_per_capita, fossil_energy_per_capita, nuclear_energy_per_capita, renewables_energy_per_capita) %>%
group_by(country)
print(energy_mix_poland)
## # A tibble: 31 × 6
## # Groups: country [1]
## year country co2_per_capita fossil_energy_per_capita nuclear_energy_per_ca…¹
## <dbl> <chr> <dbl> <dbl> <dbl>
## 1 1990 Poland 9.90 31682. 0
## 2 1991 Poland 9.79 30908. 0
## 3 1992 Poland 9.53 29478. 0
## 4 1993 Poland 9.54 29417. 0
## 5 1994 Poland 9.39 28088. 0
## 6 1995 Poland 9.45 28721. 0
## 7 1996 Poland 9.84 30150. 0
## 8 1997 Poland 9.58 29852. 0
## 9 1998 Poland 8.85 28574. 0
## 10 1999 Poland 8.6 28046. 0
## # ℹ 21 more rows
## # ℹ abbreviated name: ¹nuclear_energy_per_capita
## # ℹ 1 more variable: renewables_energy_per_capita <dbl>
energy_mix_poland_long <- energy_mix_poland %>%
pivot_longer(
cols = c(fossil_energy_per_capita, nuclear_energy_per_capita, renewables_energy_per_capita),
names_to = "energy_type",
values_to = "kwh_per_capita"
) %>%
mutate(energy_type = case_when(
energy_type == "fossil_energy_per_capita" ~ "Fossil",
energy_type == "nuclear_energy_per_capita" ~ "Nuclear",
energy_type == "renewables_energy_per_capita" ~ "Renewables"
))
combined_data_poland <- energy_mix_poland_long %>%
mutate(metric = "Energy Consumption (kWh/person)") %>%
rename(value = kwh_per_capita) %>%
bind_rows(
energy_mix_poland %>%
mutate(
metric = "CO2 Emissions (tonnes/person)",
energy_type = "CO2"
) %>%
select(year, country, metric, energy_type, value = co2_per_capita)
)
ggplot(combined_data_poland, aes(x = year, y = value, color = energy_type)) +
geom_line(linewidth = 1.2) +
scale_color_manual(
name = "Metric",
values = c("Fossil" = "#E41A1C",
"Nuclear" = "#377EB8",
"Renewables" = "#4DAF4A",
"CO2" = "black")
) +
facet_wrap(
~metric,
ncol = 1,
scales = "free_y",
strip.position = "top"
) +
scale_x_continuous(
breaks = seq(1990, 2020, by = 5),
limits = c(1990, 2020)
) +
theme(
strip.text = element_text(size = 12, face = "bold"),
strip.placement = "outside",
strip.background = element_blank(),
panel.background = element_blank(),
panel.grid = element_blank(),
axis.line = element_line(),
legend.position = "right",
legend.title = element_text(face = "bold", size = 12),
axis.title.y = element_text(size = 10, hjust = 0.5),
plot.title = element_text(face = "bold", size = 14, hjust = 0.5),
plot.subtitle = element_text(size = 12, hjust = 0.5)
) +
labs(
title = "Poland's Energy Mix and CO2 Emissions",
subtitle = "1990-2020",
x = "Year",
y = NULL,
caption = "Data: Our World in Data (2023)\nEnergy: kWh/person | CO2: tonnes/person"
)