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:
covid19sf_hospital
- a daily snapshot of the hospital capacitycovid19sf_hospitalizations
- a daily snapshot of the patients statusThe covid19sf_hospital
dataset provides a daily snapshot of the San Francisco hospital capacity by bed type and status with the following variables:
bed_type
- number of hospital beds available by department type:status
- the department corresponding bed status: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")
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:
dphcategory
- the hospital unit type, either ICU
(intensive care unit) or Med/Surg
(acute care).covidstatus
- the Covid19 status, either COVID+
(confirmed cases) or PUI
(patient under investigation)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))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.