knitr::opts_chunk$set(
  fig.height=5, fig.width=8,
   message=FALSE, warning=FALSE,
  collapse = TRUE,
  comment = "#>"
)
`%>%` <- magrittr::`%>%`
library(covid19sf)

The covid19sf package provides two datasets focusing on the overall hospital capacity and patients status in San Francisco hospitals:

Hospital Capacity

The covid19sf_hospital dataset provides a daily snapshot of the San Francisco hospital capacity by bed type and status with the following variables:

data(covid19sf_hospital)

head(covid19sf_hospital)

Let's summarise the hospital status as of the most recent date available on the dataset:

library(dplyr)

covid19sf_hospital %>%
  filter(date == max(date)) %>%
  group_by(bed_type, status) %>%
  summarise(total = sum(count))
library(plotly)

covid19sf_hospital %>%
  filter(bed_type == "Acute Care") %>%
  mutate(status = factor(status, levels = c("Other Patients", "COVID-19 (Confirmed & Suspected)", "Available"))) %>%
  plot_ly(x = ~ date,
          y = ~ count,
          type = 'scatter', 
          mode = 'none', 
          color = ~status,
          stackgroup = 'one') %>%
    layout(title = "SF Acute Hospitals - Acute Care Bed Count",
          legend = list(x = 0.05, y = 0.95),
         yaxis = list(title = "Number of Beds", tickformat = ".0f"),
         xaxis = list(title = "Source: San Francisco Department of Public Health"),
         hovermode = "compare")
covid19sf_hospital %>%
  filter(bed_type == "Intensive Care") %>%
  mutate(status = factor(status, levels = c("Other Patients", "COVID-19 (Confirmed & Suspected)", "Available"))) %>%
  plot_ly(x = ~ date,
          y = ~ count,
          type = 'scatter', 
          mode = 'none', 
          color = ~status,
          stackgroup = 'one') %>%
    layout(title = "SF Acute Hospitals - Intensive Care Bed Count",
          legend = list(x = 0.05, y = 1),
         yaxis = list(title = "Number of Beds", tickformat = ".0f"),
         xaxis = list(title = "Source: San Francisco Department of Public Health"),
         hovermode = "compare")

Covid19 Hospitalizations

The covid19sf_hospitalizations provides daily snapshot of the number of patients in San Francisco hospitals by hospitalization unit and Covid19 status using the following variables:

The below example summarised the hospitalizations status as of the most recent date in the data:

data(covid19sf_hospitalizations)

covid19sf_hospitalizations %>%
  filter(reportdate == max(reportdate)) %>%
  group_by(dphcategory, covidstatus) %>%
  summarise(total = sum(patientcount))


RamiKrispin/covid19sf documentation built on April 3, 2023, 4:11 p.m.