southafricastats: Population and Mortality Statistics for South Africa

Author: Julia Silge
License: MIT

Travis-CI Build Status

knitr::opts_chunk$set(
  collapse = TRUE,
  comment = "#>",
  fig.path = "README-"
)

This package provides a small excerpt of the data available at the South Africa Data Portal. For each of the nine provinces in South Africa, this package provides mortality numbers from several causes from 2008 to 2013 and total population from 2011 to 2016. This package was built to support my introductory Shiny workshop at the February 2017 satRday conference in Cape Town, South Africa.

Installation

You can install this package from Github with devtools:

library(devtools)
install_github("juliasilge/southafricastats")

Working with the datasets

There are two datasets in this package. The first one, population_zaf, contains total population counts for the nine provinces in South Africa for the years 2011 to 2016.

library(ggplot2)

ggplot(population_zaf, aes(year, total, color = province)) + 
    geom_line(size = 1.5, alpha = 0.7) + 
    expand_limits(y = 0) +
    labs(x = NULL, y = "Total population")

The second dataset, mortality_zaf, contains number of deaths due to various causes in the nine provinces for the years 2008 to 2013. What are the most common causes of death in these provinces?

library(dplyr)

mortality_zaf %>%
    count(indicator, sort = TRUE)

How has the number of HIV deaths in Gauteng, KwaZulu-Natal, and Eastern Cape changed over time?

mortality_zaf %>%
    filter(indicator == "Human immunodeficiency virus [HIV] disease (B20-B24)",
           province %in% c("Gauteng", "KwaZulu-Natal", "Eastern Cape")) %>%
    ggplot(aes(year, deaths, color = province)) +
    geom_line(size = 1.5, alpha = 0.7) +
    expand_limits(y = 0) +
    labs(x = NULL, y = "Number of deaths")

Please note that this project is released with a Contributor Code of Conduct. By participating in this project you agree to abide by its terms.



juliasilge/southafricastats documentation built on May 20, 2019, 4:21 a.m.