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

About

The hospitals package contains hospital related data. So far it contains the following dataset(s):

Installation

# install.packages("devtools")
devtools::install_github("jjchern/hospitals")

# To uninstall the package, use:
# remove.packages("hospitals")

Usage

library(dplyr, warn.conflicts = FALSE)
hospitals::beds_state

hospitals::beds_state %>% 
        filter(year == 2014) %>% 
        mutate(fips = sprintf("%02d", fips)) -> beds_2014
beds_2014

usmapdata::state %>% 
        left_join(beds_2014, by = c("id" = "fips")) -> beds_2014 

library(ggplot2)
ggplot() +
  geom_map(data = beds_2014, map = beds_2014,
           aes(x = long, y = lat, map_id = id, fill = total),
           colour = alpha("white", 0.5), size=0.2) +
  coord_map("albers", lat0 = 30, lat1 = 40) +
  viridis::scale_fill_viridis(option = "A") +
  ggtitle("U.S. Hospital Beds per 1,000 Population, 2014") +
  ggthemes::theme_map() +
  theme(legend.position = c(.85, .3),
        legend.title=element_blank())


jjchern/hospitals documentation built on May 19, 2019, 11:38 a.m.