knitr::opts_chunk$set(
  collapse = TRUE,
  comment = "#>",
  fig.path = "man/figures/README-",
  out.width = "100%"
)

covid19us

Travis build status AppVeyor build status Codecov test coverage CRAN status License: MIT

This is an R wrapper around the COVID Tracking Project API. It provides updates on the spread of the virus in the US with a few simple functions.

Installation

install.packages("covid19us")

Or the dev version:

devtools::install_github("aedobbyn/covid19us")

Examples

library(covid19us)

Get the most recent COVID-19 top-line data for the country:

get_us_current()

Or the same by state:

get_states_current()

Daily state counts can be filtered by state and/or date:

get_states_daily(
  state = "NY", 
  date = "2020-03-17"
)

For data in long format:

(dat <- refresh_covid19us())

Which can be easier to plot

library(dplyr)
library(ggplot2)

dat %>% 
  filter(
    location == "NY" &
      data_type %in% 
      c(
        "positive_increase",
        "total_test_results_increase",
        "death_increase",
        "hospitalized_increase"
      )
  ) %>% 
  mutate(
    Type = data_type %>% 
      stringr::str_replace_all("_", " ") %>% 
      stringr::str_to_title()
  ) %>% 
  arrange(date) %>% 
  ggplot(aes(date, value, color = Type)) +
  geom_smooth(se = FALSE) + 
  scale_x_date(date_breaks = "2 weeks") +
  labs(title = "COVID in NY") +
  xlab("Date") +
  ylab("Value") +
  theme_minimal(base_family = "Source Sans Pro")

To get information about the data:

get_info_covid19us()

All Functions

get_counties_info
get_info_covid19us
get_states_current
get_states_daily
get_states_info
get_tracker_urls
get_us_current
get_us_daily
refresh_covid19us

Other Details


PRs and bug reports / feature requests welcome. Stay safe!



aedobbyn/covid19us documentation built on Aug. 7, 2022, 3:17 a.m.