R - getting demographic data

Ilya Kashnitsky

13 December 2016

Examples of data visualization

http://www.global-migration.info

http://www.demogr.mpg.de/papers/working/wp-2015-008.pdf

http://www.oeaw.ac.at/fileadmin/subsites/Institute/VID/dataexplorer/index.html

https://twitter.com/revodavid/status/808405998985740289
https://twitter.com/albertocairo/status/805944911010918400
https://twitter.com/rettungstweet/status/801012883026898945
https://twitter.com/bill_easterly/status/799988679439548416
https://twitter.com/simongerman600/status/799006705808003076
https://twitter.com/MaxCRoser/status/798525588835213312
https://twitter.com/rettungstweet/status/794479395163533312
https://twitter.com/dgoldenberg/status/783785617532395520
https://twitter.com/ikashnitsky/status/802310186560081920
https://twitter.com/ikashnitsky/status/785973218775478273

http://toddwschneider.com/posts/ballr-interactive-nba-shot-charts-with-r-and-shiny

Built-in datasets

https://vincentarelbundock.github.io/Rdatasets/datasets.html

Exercise

  • Grab any built-in dataset
  • Create a visualization using ggplot2

example

# try datasets::

df <- airquality

ggplot(df)+
        stat_ecdf(aes(x = Temp, color = factor(Month)), size=1)+
        scale_color_viridis(option = "B", discrete = T, end = .8)+
        theme_fivethirtyeight()+
        theme(legend.position = c(.1,.8))

External packages for data

The data packages

gapminder eurostat
wpp2015
HMDHFDplus
OECD
WDI
acs

Russian data (Boris Demeshev)

http://bdemeshev.github.io/r_cycle/cycle_files/23_load_rus_data.html

gapminder

https://www.gapminder.org

Exercise

  • Compare e0 distributions in 1957, 1982, and 2007

eurostat

How to find the needed dataset

http://ec.europa.eu/eurostat/data/database
http://ec.europa.eu/eurostat/estat-navtree-portlet-prod/BulkDownloadListing

wpp2015

https://esa.un.org/unpd/wpp/

HMDHFDplus

Human Mortality Database

http://www.mortality.org

How to store login data safely

Exercise

Replicate the graph
https://twitter.com/ikashnitsky/status/802310186560081920

https://gist.github.com/ikashnitsky/872d3a97390a60d26eeb64f0f5600067

OECD

Organisation for Economic Co-operation and Development

http://www.oecd.org

WDI

World Bank’s World Development Indicators

http://data.worldbank.org/data-catalog/world-development-indicators

acs

American Community Survey