Domestic Emissions (UNFCCC) Including LULUCF Downloaded from climatewatchdata.org, from year 1995-2018
library(tidyverse)
── 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.4.4 ✔ tibble 3.2.1
✔ lubridate 1.9.3 ✔ 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
library(countrycode)library(readxl)library(dplyr)#Read excel filedomestic <-read_excel("data-raw/domestic_ghg.xlsx",skip =1)#Pivot to longdomestic_longer <- domestic |>slice(1:(n() -2)) |>pivot_longer(cols =`1995`:`2018`,names_to ="year",values_to ="scp1_domestic_emissions" ) |>mutate(year =as.numeric(year) )#Write excel to data folderlibrary(openxlsx)write.xlsx(domestic_longer, "data/scp1_domestic_emissions.xlsx")
Emissions of Exports of Goods and Services Downloaded from OECD, from year 1995-2018 Indicator: EXGR_DCO2: Domestic CO2 emissions embodied in gross exports Industry: DTOTAL: TOTAL
Grid-supplied electricity, steam and cooling imports Downloaded from OECD, from year 1995-2018 Indicator: IMGR_DCO2: Domestic CO2 emissions embodied in gross imports Industry: D35: Electricity, gas, steam and air conditioning supply
Combine Scope 2 and Scope 1 Emissions into one sheet
combined_scp1 <-read_excel("data/combined_scp1.xlsx") import_d35_longer <-read_excel("data/scp2_emissions.xlsx")combined_scp1_scp2 <-inner_join(combined_scp1, import_d35_longer, by =c("country"="country", "year"="year")) |>select(-`iso`)combined_scp1_scp2
# A tibble: 768 × 8
iso.x country unit year scp1_domestic_emissi…¹ scp1_export_emissions
<chr> <chr> <chr> <dbl> <dbl> <dbl>
1 USA United States MtCO2e 1995 5762. 355.
2 USA United States MtCO2e 1996 5933. 365.
3 USA United States MtCO2e 1997 6193. 396.
4 USA United States MtCO2e 1998 6241. 380.
5 USA United States MtCO2e 1999 6243. 389.
6 USA United States MtCO2e 2000 6406. 410.
7 USA United States MtCO2e 2001 6368. 377.
8 USA United States MtCO2e 2002 6216. 320.
9 USA United States MtCO2e 2003 6280. 305.
10 USA United States MtCO2e 2004 6363. 329.
# ℹ 758 more rows
# ℹ abbreviated name: ¹scp1_domestic_emissions
# ℹ 2 more variables: scp1_total_emissions <dbl>, scp2_emissions <dbl>
Import and Clean Total Import Emissions Downloaded from OECD, from year 1995-2018 Indicator: IMGR_DCO2: Domestic CO2 emissions embodied in gross imports Industry: DTOTAL: TOTAL