###pivot longer each data set and select variables neededsovereign_emssion_long <- sovereign_ems |>pivot_longer(cols=starts_with('Y_'),names_to ='year',values_to ='sovereign_emission' ) |>mutate(year=parse_number(year)) |>select('Country_code_A3','Name', 'year','sovereign_emission')sovereign_emssion_long
#### standardzied country names and codes#sovereign_emssion_long |># mutate(iso3c = country_regex_to_iso3c(Name))# Warning: the following five country names cannot be parsed through the countrycode package,and these are not found in the next two data sets. 'Int. Aviation'|>country_regex_to_iso3c()
Warning: Some values were not matched unambiguously: Int. Aviation
[1] NA
'Int. Shipping'|>country_regex_to_iso3c()
Warning: Some values were not matched unambiguously: Int. Shipping
[1] NA
'Netherlands Antilles'|>country_regex_to_iso3c()
Warning: Some values were not matched unambiguously: Netherlands Antilles
[1] NA
'Serbia and Montenegro'|>country_regex_to_iso3c()
Warning: Some values were not matched unambiguously: Serbia and Montenegro
[1] NA
'Virgin Islands_USA '|>country_regex_to_iso3c()
Warning: Some values were not matched unambiguously: Virgin Islands_USA
[1] NA
#PPP_GDP_long |># mutate(iso3c = country_regex_to_iso3c(Name))#########Unfortunately a lot of the variables cannot be parsed, as they are region names: Africa Eastern and Southern, Africa Western and Central, Arab World, Caribbean small states, Central Europe and the Baltics, Early-demographic dividend, East Asia & Pacific, East Asia & Pacific (excluding high income), East Asia & Pacific (IDA & IBRD countries), Euro area, Europe & Central Asia, Europe & Central Asia (excluding high income), Europe & Central Asia (IDA & IBRD countries), European Union, Fragile and conflict affected situations, Heavily indebted poor countries (HIPC), High income, IBRD only, IDA & IBRD total, IDA blend, IDA only, IDA total, Kosovo, Late-demographic dividend, Latin America & Caribbean, Latin America & Caribbean (excluding high income), Latin America & the Caribbean (IDA & IBRD countries), Least developed countries: UN classification, Low & middle income, Low income, Lower middle income, Middle East & North Africa, Middle East & North Africa (excluding high income), Middle East & North Africa (IDA & IBRD countries), Middle income, North America, OECD members, Other small states, Pacific island small states, Post-demographic dividend, Pre-demographic dividend, Small states, South Asia, South Asia (IDA & IBRD), Sub-Saharan Africa, Sub-Saharan Africa (excluding high income), Sub-Saharan Africa (IDA & IBRD countries), Upper middle income, World #outstanding_debt_long |># mutate(iso3c = country_regex_to_iso3c(Name))#Same as before, there are a lof of unrexignized regional variables:East Asia & Pacific (excluding high income), Europe & Central Asia (excluding high income), IDA only, IDA total, Kosovo, Latin America & Caribbean (excluding high income), Least developed countries: UN classification, Low & middle income, Low income, Lower middle income, Middle East & North Africa (excluding high income), Middleincome, South Asia, Sub-Saharan Africa (excluding high income), Upper middle income'Kosovo'|>country_regex_to_iso3c()
Warning: Some values were not matched unambiguously: Kosovo
[1] NA
#This variable is the only unmatched country variable from the last two data set, but it is not included in the sovereign_emission_long data set.#Therefore, we have to drop these variables then standardizesovereign_emission_long2 <- sovereign_emssion_long |>filter(Name !="Int. Aviation"& Name !="Int. Shipping"& Name !="Netherlands Antilles"& Name !="Serbia and Montenegro"& Name !="Virgin Islands_USA") |>mutate(iso3c =country_regex_to_iso3c(Name),country_name =iso3c_to_country_name(iso3c)) |>select("iso3c", "country_name", "year", "sovereign_emission")PPP_GDP_long2 <- PPP_GDP_long |>filter( Name !="Africa Eastern and Southern", Name !="Africa Western and Central", Name !="Arab World", Name !="Caribbean small states", Name !="Central Europe and the Baltics", Name !="Early-demographic dividend", Name !="East Asia & Pacific", Name !="East Asia & Pacific (excluding high income)", Name !="East Asia & Pacific (IDA & IBRD countries)", Name !="Euro area", Name !="Europe & Central Asia", Name !="Europe & Central Asia (excluding high income)", Name !="Europe & Central Asia (IDA & IBRD countries)", Name !="European Union", Name !="Fragile and conflict affected situations", Name !="Heavily indebted poor countries (HIPC)", Name !="High income", Name !="IBRD only", Name !="IDA & IBRD total", Name !="IDA blend", Name !="IDA only", Name !="IDA total", Name !="Kosovo", Name !="Late-demographic dividend", Name !="Latin America & Caribbean", Name !="Latin America & Caribbean (excluding high income)", Name !="Latin America & the Caribbean (IDA & IBRD countries)", Name !="Least developed countries: UN classification", Name !="Low & middle income", Name !="Low income", Name !="Lower middle income", Name !="Middle East & North Africa", Name !="Middle East & North Africa (excluding high income)", Name !="Middle East & North Africa (IDA & IBRD countries)", Name !="Middle income", Name !="North America", Name !="OECD members", Name !="Other small states", Name !="Pacific island small states", Name !="Post-demographic dividend", Name !="Pre-demographic dividend", Name !="Small states", Name !="South Asia", Name !="South Asia (IDA & IBRD)", Name !="Sub-Saharan Africa", Name !="Sub-Saharan Africa (excluding high income)", Name !="Sub-Saharan Africa (IDA & IBRD countries)", Name !="Upper middle income", Name !="World" )|>mutate(iso3c =country_regex_to_iso3c(Name),country_name =iso3c_to_country_name(iso3c))|>select("iso3c", "country_name", "year", "PPP_GDP")outstanding_debt_long2 <- outstanding_debt_long |>filter( Name !="East Asia & Pacific (excluding high income)", Name !="Europe & Central Asia (excluding high income)", Name !="IDA only", Name !="IDA total", Name !="Kosovo", Name !="Latin America & Caribbean (excluding high income)", Name !="Least developed countries: UN classification", Name !="Low & middle income", Name !="Low income", Name !="Lower middle income", Name !="Middle East & North Africa (excluding high income)", Name !="Middle income", Name !="South Asia", Name !="Sub-Saharan Africa (excluding high income)", Name !="Upper middle income" ) |>mutate(iso3c =country_regex_to_iso3c(Name),country_name =iso3c_to_country_name(iso3c))|>select("iso3c", "country_name", "year", "outstanding_debt")sovereign_emission_long2
# A tibble: 11,554 × 7
iso3c country_name year sovereign_emission outstanding_debt PPP_GDP
<chr> <chr> <dbl> <dbl> <dbl> <dbl>
1 ABW Aruba 1970 45.2 NA NA
2 ABW Aruba 1971 50.1 NA NA
3 ABW Aruba 1972 60.9 NA NA
4 ABW Aruba 1973 65.8 NA NA
5 ABW Aruba 1974 65.1 NA NA
6 ABW Aruba 1975 79.1 NA NA
7 ABW Aruba 1976 78.2 NA NA
8 ABW Aruba 1977 88.9 NA NA
9 ABW Aruba 1978 93.7 NA NA
10 ABW Aruba 1979 97.7 NA NA
# ℹ 11,544 more rows
# ℹ 1 more variable: financed_emission <dbl>
Note that emission for some of the years are NA due to missing data from different data sources, we thus drop the missing ones and give meaning labels to the data set: