Projections Project


Developing Data Products

Assignment



Ian

BugBunny

Population Projections

for the UK

  • The assignment was to code and deploy an interactive web app using the R package shiny.

  • 'Demography is destiny' according to Auguste Comte, or maybe Wattenberg and Scammon (1970).

  • This app computes population projections for the United Kingdom for 2015-50 using forecasts of total fertility chosen by the user. It can produce a population pyramid for the mid- or end-point of any decade within this period that the user selects.

  • Thereby, it enables the user to visualize how changes in the birth rate might affect the future size and age structure of the British population.

A static population pyramid

library(plotrix); par(mar = pyramid.plot(Men, Women, gap = 250,  
   lxcol = "steelblue", rxcol = "plum", unit = "000s", labels = agelab,
   main = "United Kingdom", top.labels = c("Men", "2015", "Women")))

plot of chunk unnamed-chunk-2

The power of shiny


The app demonstrates several features of shiny:


  • Panelled web page layouts, including tabbed panels
  • Use of widgets for input (sliders, dropdown boxes)
  • Reactive code that runs if the sliders change, but not when the dropdown box does
  • Two types of reactive output (text and a chart)
  • Web hosting on the shiny apps server

Accessing the app and the code


The app is hosted on RStudio's shiny apps server:
https://bugbunny.shinyapps.io/ProjectionsProject


The R scripts containing the code are on GitHub:
https://github.com/BugBunny/ProjectionsProject


Projections App. Copyright (C) 2015 - Ian Timaeus

This program comes with ABSOLUTELY NO WARRANTY; this is free software, and you are welcome to redistribute it under certain conditions; see http://www.gnu.org/licenses/gpl.html