There are numerous indicators published by the World Bank which deal with topics varying from agriculture to urban development. This is a quick lesson on how to use their open datasets to download and compare metrics of choice between two countries. In this document, I will be comparing the hospital bed density between the United States and India.

Why hospital beds?

What is included in the data?

Let’s get started.

Let’s install libraries

library(tidyverse)
library(wbstats)
library(knitr)

Accessing the data

We will be using the wb() function from the wbstats package to download data from the World Bank API. I have covered this function in my previous post comparing life expectancies around the world.

dat <- (wb(country = "all", indicator = "SH.MED.BEDS.ZS", mrv = 50))
#"SH.MED.BEDS.ZS" is the World Bank indicator code that holds the beds per 1000 values.
#mrv = 50 indicates that we want the 50 most recent values.

Building the base map

We will use dplyr pipes to filter for India and the US, and build a base plot.

dat_plot <- dat %>% filter( iso3c %in% c("IND", "USA")) %>% 
  select(Country = iso3c, Year = date, Beds_Per_1000 = value ) %>% 
  ggplot()

Adding the mapping

Let us add a scatterplot with jitter to this map to represent the number of hospital beds available for 1000 persons for both countries. I’ve chosen to label the X axis at 5-year intervals.

dat_plot + geom_jitter(aes( x = Year, y = Beds_Per_1000, color = Country)) + 
  theme(axis.text.x = element_text(angle = 90, hjust = 1)) + 
  ylab("Beds Per 1000") + 
  ggtitle("Hospital Bed Density — \n India and the US") +
  scale_x_discrete(breaks=seq(1970, 2013, by = 5)) + scale_color_brewer(palette="Dark2")

What do you think?

Limitations

We do not really have a good idea of what an ideal hospital density is. A density of 2 might be great for one country, but very inadequate for another. Another interesting thing I learned about today was Roemer’s Law, which states that hospital beds that are built tend to be used— the study found statistically significant relationships betwee hospitalization rates and availabilty of hospital beds.