App pitch: Per capita CO2 emissions and GDP categories.

Nicolas Saunier
3/3/2020

Overview

This application shows the link between GDP and CO2 emissions. The user can use a slider to select the category of countries they want to look at. Based on the users input, the application will return information about the CO2 emissions in that category.

All original data was collected from the world bank site, accessed on 28/2/2020.
GDP per capita : https://data.worldbank.org/indicator/NY.GDP.PCAP.PP.CD
CO2 Metric Tons: https://data.worldbank.org/indicator/EN.ATM.CO2E.PC

This app can be found here: https://nicsaunier.shinyapps.io/co2_gdp_quintiles/

Preprocessing

The data on gdp and the data on CO2 is combined into a table called gcdata.

  Country_Name  CO2_2014  GDP_2014         gdpcat underParis
1  Afghanistan 0.2939464  1897.526 [  711,  3756)          1
2      Albania 1.9787633 11259.226 [ 9664, 16018)          1
3      Algeria 3.7355201 14326.283 [ 9664, 16018)          0

The data on quintiles was first obtained by running the cut2 function from the Hmisc package. Then the countries with the least and most CO2 emissions for each quintile were found. Mean emissions and the percent of countries in each category that were under the Paris target of 2t of CO2 emissions per capita in 2014 were calculated.

The first few rows of the resulting table, which is stored in an R object called quintdata.

        quintile     Best    BestCO2   BestGDP            Worst  WorstCO2
1 [  711,  3756)  Burundi 0.04469999   812.030 Marshall Islands  1.795694
2 [ 3756,  9664)   Zambia 0.29241222  3893.549          Ukraine  5.020747
3 [ 9664, 16018) Paraguay 0.86402948 11486.944     Turkmenistan 12.517096
   WorstGDP   meanCO2 percentunderParis qn
1  3443.028 0.4159181             100.0  1
2  8710.749 1.3001638              87.2  2
3 15144.545 4.0388475              19.1  3

Text output

When the user moves the slider, the quint data is filtered in a reactive way. Example value of quintdata for a slider value of 1:

library(dplyr)
filter(quintdata, qn == 1)
        quintile    Best    BestCO2 BestGDP            Worst WorstCO2 WorstGDP
1 [  711,  3756) Burundi 0.04469999  812.03 Marshall Islands 1.795694 3443.028
    meanCO2 percentunderParis qn
1 0.4159181               100  1

The data from the filtered dataframe is then used to fill in the blanks in the text.

Plot output

The points in the plot change format based on which value is selected with the slider. A line showing the mean CO2 emissions for countries in the selected category makes it possible for the user to compare those emissions with the Paris targets.
All lines can be displayed or not based on tickbox input from the user.

Example plot for a slider value of 3

plot of chunk unnamed-chunk-4