Warning: package 'rnaturalearth' was built under R version 4.1.3
library(countrycode)
Warning: package 'countrycode' was built under R version 4.1.3
library(wbstats)
Warning: package 'wbstats' was built under R version 4.1.3
Here, I read in data for domestic emissions from 1990 to 2018.
scope_1_domestic <-read_csv("~/Raw Data Finace Project 2/Scope 1 Emissions.csv")
Rows: 193 Columns: 31
-- Column specification --------------------------------------------------------
Delimiter: ","
chr (3): Country/Region, unit, 1990
dbl (28): 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, ...
i Use `spec()` to retrieve the full column specification for this data.
i Specify the column types or set `show_col_types = FALSE` to quiet this message.
Warning in countrycode_convert(sourcevar = sourcevar, origin = origin, destination = dest, : Some values were not matched unambiguously: APEC: Asia-Pacific Economic Cooperation, ASEAN: Association of South East Asian Nations, Data extracted on 12 Mar 2023 22:29 UTC (GMT) from OECD.Stat, EA19: Euro area (19 countries), EASIA: Eastern Asia, EU13: EU28 excluding EU15, EU15: European Union (15 countries), EU27_2020: European Union (27 countries), EU28: European Union (28 countries), G20: Group of Twenty, NONOECD: Non-OECD economies and aggregates, OECD: OECD member countries, ROW: Rest of the World, TUR: Türkiye, ZASI: East and Southeastern Asia, ZEUR: Europe, ZNAM: North America, ZOTH: Other regions, ZSCA: South and Central America
Delete empty data entries.
scope_1_export <- scope_1_export %>%na.omit()
Join domestic emissions and export emissions so that I now have all scope 1 emissions data.
scope_1_and_export <-full_join(scope_1_domestic, scope_1_export, by =c("year"="year", "country_name"="country_name", "iso3c"="iso3c"))
Read in scope 2 emissions info from data base.
scope_2 <-read_excel("~/Raw Data Finace Project 2/Scope 2 Emissions.xlsx", skip =6)
I clean the data so that year is one column and scope 2 emissions are one column.
Warning in countrycode_convert(sourcevar = sourcevar, origin = origin, destination = dest, : Some values were not matched unambiguously: APEC: Asia-Pacific Economic Cooperation, ASEAN: Association of South East Asian Nations, Data extracted on 12 Mar 2023 22:34 UTC (GMT) from OECD.Stat, EA19: Euro area (19 countries), EASIA: Eastern Asia, EU13: EU28 excluding EU15, EU15: European Union (15 countries), EU27_2020: European Union (27 countries), EU28: European Union (28 countries), G20: Group of Twenty, NONOECD: Non-OECD economies and aggregates, OECD: OECD member countries, ROW: Rest of the World, TUR: Türkiye
Omit missing data
scope_2 <- scope_2 %>%na.omit()
Download scope 3 emissionds data.
scope_3 <-read_excel("~/Raw Data Finace Project 2/Scope 3 Emissions.xlsx", skip =6)
rearrange data so that year is in a column and scope 3 emissions are in a column.
Warning in countrycode_convert(sourcevar = sourcevar, origin = origin, destination = dest, : Some values were not matched unambiguously: APEC: Asia-Pacific Economic Cooperation, ASEAN: Association of South East Asian Nations, EA19: Euro area (19 countries), EASIA: Eastern Asia, EU13: EU28 excluding EU15, EU15: European Union (15 countries), EU27_2020: European Union (27 countries), EU28: European Union (28 countries), G20: Group of Twenty, NONOECD: Non-OECD economies and aggregates, OECD: OECD member countries, ROW: Rest of the World, TUR: Türkiye, ZASI: East and Southeastern Asia, ZEUR: Europe, ZNAM: North America, ZOTH: Other regions, ZSCA: South and Central America
Remove missing data.
scope_3 <- scope_3 %>%na.omit()
combine scope 1 and scope 2 emissions data.
scopes_1_and_2 <-full_join(scope_1_and_export, scope_2, , by =c("year"="year", "country_name"="country_name", "iso3c"="iso3c"))
Combine scope 1, 2 and 3 emissions data into one data base.
all_scopes_all_data <-full_join(scopes_1_and_2, scope_3, , by =c("year"="year", "country_name"="country_name", "iso3c"="iso3c"))
Remove data for years that do not have all kinds of emissions
Add nominal GDP tp data set with scopes 1-3 emissions and GDP PPP.
all_data_scopes_GDP_PPP_and_nom_na <-full_join(all_data_scopes_GDP_PPP, nom_GDP, , by =c("year"="year", "country_name"="country_name", "iso3c"="iso3c"))
Remove data for countries that do not have data on scopes 1-3 emissions, nominal GDP, and PPPGDP in a given year. This limits the data to being from 1995-2018.