Visualizing the DHS Data

Let us load the data we will need:

dhs14_design <- readRDS("data/dhs14_design.RDS")
dhs.df14 <- readRDS("data/dhs.df14.RDS")

Visualizing Data

Three common ways to generate basic graphics in R are via - base R - lattice - ggplot2

We will skip base R graphics since ggplot2 will be the graphics package for this class. Let us see how we use it, starting with a simple bar-chart

Remember the typical options…

ggplot2 can work with unit-level data (i.e., one row per observation) AND it can also work with calculated values stored in a data-frame (like our survey-weighted estimates from BRFSS/DHS)

we will see both ways in action

Bar-charts

Educational Attainment (educ)

library(ggplot2)
ggplot(data = dhs.df14, aes(x = educat)) + geom_bar()

Educational attainment by Wealth quintiles

ggplot(data = dhs.df14, aes(x = educat, group = wealthq, fill = wealthq)) +
  geom_bar()