Carbon Dioxide Emissions

Global Evolution of CO$_2$ per Capita from 1990 to 2007

Eugene
Developing Data Products Project

Introduction

This is the month of COP21, the climate change conference in Paris, so it seemed appropriate to produce a shinyApp dealing with the issue of CO\(_2\) emissions. The App, available at https://eugene100hickey.shinyapps.io/myapp, looks at annual CO\(_2\) emissions per capita for countries around the globe. The year can be selected between 1990 and 2007. Emission levels are indicated by colour (light green for high-achievers, red for the polluters). The actual emission level can be seen by mouse hover.

The App also permits us to zoom in on a particular continent, the options are given as a series of radio buttons on left screen.

The data comes from wikipedia, specifically:
https://en.wikipedia.org/wiki/List_of_countries_by_carbon_dioxide_emissions_per_capita.

Example

The image belows shows the App in action. The year 2000 is chosen, the geographical area of Europe is selected, and the mouse is placed over Ireland, showing carbon dioxide emissions of 10.7 tonnes per capita. We investigate by running an r chunk in slidify with result: 10.7

Europe1.png

At a glance you can see that countries like Sweden and France do pretty well, Luxembourg and the Czech Republic not so much

ShinyApp Code - UI.R

shinyUI(pageWithSidebar(
  headerPanel("Carbon Dioxide Emissions per Capita in Metric Tonnes"),
  sidebarPanel(
    radioButtons(inputId = "area", 
                 label = "Choose Region",
                 choices = c("World" = "world",
                             "Europe" = "150",
                             "Asia" = "142",
                             "North America" = "021",
                             "South America" = "005",
                             "Africa" = "002",
                             "Oceania" = "009")
                 ),
    sliderInput('year', 'Choose Year',value = 2000, min = 1990, 
    max = 2007, step = 1,sep="", animate=T)),
  mainPanel(
    htmlOutput("G2")
  )
))

ShinyApp Code - server.R (or at least the active part)

shinyServer(
  function(input, output){
    output$G2 =renderGvis ({
      area = input$area
      year = input$year
      gvisGeoChart(data=CO2, 
                   locationvar="Country", 
                   colorvar=year,
                   options=list(region=area,
                                colorAxis="{colors:['lightgreen', 'crimson']}",
                                width = 600, height = 400)
                   )
    })
  }
)

Note the use of gvisGeoChart from the googleVis package.