covid19us/0000755000176200001440000000000013725357443012115 5ustar liggesuserscovid19us/NAMESPACE0000644000176200001440000000056013723203135013317 0ustar liggesusers# Generated by roxygen2: do not edit by hand export("%<>%") export("%>%") export(get_counties_info) export(get_info_covid19us) export(get_states_current) export(get_states_daily) export(get_states_info) export(get_tracker_urls) export(get_us_current) export(get_us_daily) export(refresh_covid19us) import(dplyr) importFrom(magrittr,"%<>%") importFrom(magrittr,"%>%") covid19us/LICENSE0000644000176200001440000000005313634301413013101 0ustar liggesusersYEAR: 2020 COPYRIGHT HOLDER: Amanda Dobbyn covid19us/README.md0000644000176200001440000001707513661126714013400 0ustar liggesusers # covid19us [![Travis build status](https://travis-ci.org/aedobbyn/covid19us.svg?branch=master)](https://travis-ci.org/aedobbyn/covid19us) [![AppVeyor build status](https://ci.appveyor.com/api/projects/status/github/aedobbyn/covid19us?branch=master&svg=true)](https://ci.appveyor.com/project/aedobbyn/covid19us) [![Codecov test coverage](https://codecov.io/gh/aedobbyn/covid19us/graph/badge.svg)](https://codecov.io/gh/aedobbyn/covid19us) [![CRAN status](https://www.r-pkg.org/badges/version/covid19us)](https://CRAN.R-project.org/package=covid19us) [![License: MIT](https://img.shields.io/badge/License-MIT-blue.svg)](https://opensource.org/licenses/MIT) This is an R wrapper around the [COVID Tracking Project API](https://covidtracking.com/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 ``` r library(covid19us) ``` Get the most recent COVID-19 top-line data for the country: ``` r get_us_current() #> # A tibble: 1 x 18 #> positive negative pending hospitalized_cu… hospitalized_cu… in_icu_currently #> #> 1 1520778 10713209 2944 41174 159634 9829 #> # … with 12 more variables: in_icu_cumulative , #> # on_ventilator_currently , on_ventilator_cumulative , #> # recovered , hash , last_modified , death , #> # hospitalized , total , total_test_results , notes , #> # request_datetime ``` Or the same by state: ``` r get_states_current() #> # A tibble: 56 x 30 #> state positive positive_score negative_score negative_regula… #> #> 1 AK 399 1 1 1 #> 2 AL 12376 1 1 0 #> 3 AR 4923 1 1 1 #> 4 AZ 14566 1 1 0 #> 5 CA 81795 1 1 0 #> 6 CO 22202 1 1 1 #> 7 CT 38430 1 1 1 #> 8 DC 7434 1 1 1 #> 9 DE 8037 1 1 1 #> 10 FL 46944 1 1 1 #> # … with 46 more rows, and 25 more variables: commercial_score , #> # grade , score , notes , data_quality_grade , #> # negative , pending , hospitalized_currently , #> # hospitalized_cumulative , in_icu_currently , #> # in_icu_cumulative , on_ventilator_currently , #> # on_ventilator_cumulative , recovered , last_update , #> # check_time , death , hospitalized , total , #> # total_test_results , fips , date_modified , #> # date_checked , hash , request_datetime ``` Daily state counts can be filtered by state and/or date: ``` r get_states_daily( state = "NY", date = "2020-03-17" ) #> # A tibble: 1 x 27 #> date state positive negative pending hospitalized_cu… hospitalized_cu… #> #> 1 2020-03-17 NY 1700 5506 NA 325 NA #> # … with 20 more variables: in_icu_currently , in_icu_cumulative , #> # on_ventilator_currently , on_ventilator_cumulative , #> # recovered , data_quality_grade , last_update , hash , #> # date_checked , death , hospitalized , total , #> # total_test_results , fips , death_increase , #> # hospitalized_increase , negative_increase , #> # positive_increase , total_test_results_increase , #> # request_datetime ``` For data in long format: ``` r (dat <- refresh_covid19us()) #> # A tibble: 80,123 x 7 #> date location location_type location_code location_code_t… data_type #> #> 1 2020-05-19 AK state 02 fips_code positive #> 2 2020-05-19 AK state 02 fips_code negative #> 3 2020-05-19 AK state 02 fips_code pending #> 4 2020-05-19 AK state 02 fips_code hospital… #> 5 2020-05-19 AK state 02 fips_code hospital… #> 6 2020-05-19 AK state 02 fips_code in_icu_c… #> 7 2020-05-19 AK state 02 fips_code in_icu_c… #> 8 2020-05-19 AK state 02 fips_code on_venti… #> 9 2020-05-19 AK state 02 fips_code on_venti… #> 10 2020-05-19 AK state 02 fips_code recovered #> # … with 80,113 more rows, and 1 more variable: value ``` Which can be easier to plot ``` r 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: ``` r get_info_covid19us() #> # A tibble: 1 x 10 #> data_set_name package_name function_to_get… data_details data_url license_url #> #> 1 covid19us covid19us refresh_covid19… Open Source… https:/… https://gi… #> # … with 4 more variables: data_types , location_types , #> # spatial_extent , has_geospatial_info ``` ## 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 - All of the data sources can be found with `get_tracker_urls()` - The `filter` column gives information about how the [COVID Tracking Project’s scraper](https://github.com/COVID19Tracking/covid-tracking) currently scrapes data from the page (xpaths, CSS selectors, functions used, etc.) - State breakdowns include DC as well as some US territories including American Samoa (AS), Guam (GU), Northern Mariana Islands (MP), Puerto Rico (PR), and the Virgin Islands (VI) - Acronyms - PUI: persons under investigation - PUM: persons under monitoring (one step before PUI) - Time zone used is Eastern Standard Time ----- **[PR](https://github.com/aedobbyn/covid19us/pulls)s and [bug reports / feature requests](https://github.com/aedobbyn/covid19us/issues) welcome.** Stay safe\! covid19us/man/0000755000176200001440000000000013671533146012664 5ustar liggesuserscovid19us/man/assignment_pipe.Rd0000644000176200001440000000043013634322606016331 0ustar liggesusers% Generated by roxygen2: do not edit by hand % Please edit documentation in R/utils-pipe.R \name{\%<>\%} \alias{\%<>\%} \title{Assignment pipe operator} \usage{ lhs \%<>\% rhs } \description{ See \code{magrittr::\link[magrittr:compound]{\%<>\%}} for details. } \keyword{internal} covid19us/man/refresh_covid19us.Rd0000644000176200001440000000105113651360045016506 0ustar liggesusers% Generated by roxygen2: do not edit by hand % Please edit documentation in R/get.R \name{refresh_covid19us} \alias{refresh_covid19us} \title{Get state data in long format} \usage{ refresh_covid19us(type = "daily") } \arguments{ \item{type}{One of \code{"daily"} or \code{"current"}} } \value{ A tibble of data retrieved with \code{\link{get_states_daily}} or \code{\link{get_states_current}} in long format with a \code{data_type} and a \code{value} column. } \description{ Get state data in long format } \examples{ \donttest{ refresh_covid19us() } } covid19us/man/get_states_current.Rd0000644000176200001440000000070113635213154017047 0ustar liggesusers% Generated by roxygen2: do not edit by hand % Please edit documentation in R/get.R \name{get_states_current} \alias{get_states_current} \title{Get current counts for every state} \usage{ get_states_current() } \value{ A tibble with one row per state and columns for individuals' COVID statuses (positive, negative, pending, death) and their total. } \description{ Get current counts for every state } \examples{ \donttest{ get_states_current() } } covid19us/man/get_info_covid19us.Rd0000644000176200001440000000065113651360045016647 0ustar liggesusers% Generated by roxygen2: do not edit by hand % Please edit documentation in R/get.R \name{get_info_covid19us} \alias{get_info_covid19us} \title{Get info about this dataset} \usage{ get_info_covid19us() } \value{ A tibble with information about where the data is pulled from, details about the dataset, what the data types are, etc. } \description{ Get info about this dataset } \examples{ \donttest{ get_info_covid19us() } } covid19us/man/get_states_info.Rd0000644000176200001440000000076113635213154016326 0ustar liggesusers% Generated by roxygen2: do not edit by hand % Please edit documentation in R/get.R \name{get_states_info} \alias{get_states_info} \title{Get COVID-related information for each state} \usage{ get_states_info() } \value{ A tibble with one row per state incluing information on the state's \code{data_site} where the data was pulled from and the \code{covid_19_site} where data is published. } \description{ Get COVID-related information for each state } \examples{ \donttest{ get_states_info() } } covid19us/man/get_states_daily.Rd0000644000176200001440000000156713635213131016475 0ustar liggesusers% Generated by roxygen2: do not edit by hand % Please edit documentation in R/get.R \name{get_states_daily} \alias{get_states_daily} \title{Get daily counts for every state} \usage{ get_states_daily(state = "all", date = "all") } \arguments{ \item{state}{State abbreviation for a specific state or all states with \code{"all"}.} \item{date}{For a specific date, a character or date vector of length 1 coercible to a date with \code{lubridate::as_date()}.} } \value{ A tibble with one row per state for all dates available with columns for individuals' COVID statuses (positive, negative, pending, death) and their total. } \description{ Daily counts are updated every day at 4pm EST. This is the only function that takes arguments. } \examples{ \donttest{ get_states_daily() get_states_daily("NY", "2020-03-17") get_states_daily(state = "WA") get_states_daily(date = "2020-03-11") } } covid19us/man/get_tracker_urls.Rd0000644000176200001440000000112113635213154016477 0ustar liggesusers% Generated by roxygen2: do not edit by hand % Please edit documentation in R/get.R \name{get_tracker_urls} \alias{get_tracker_urls} \title{Get URLs and their details for each state} \usage{ get_tracker_urls() } \value{ A tibble with one row for every state, the URL used by scrapers to get data, and a \code{filter} column that provices the xpath or CSS selector used by the \href{https://github.com/COVID19Tracking/covid-tracking}{COVID-19 Tracking Project's scraper} to get this data. } \description{ Get URLs and their details for each state } \examples{ \donttest{ get_tracker_urls() } } covid19us/man/figures/0000755000176200001440000000000013671533147014331 5ustar liggesuserscovid19us/man/figures/README-unnamed-chunk-6-1.png0000644000176200001440000013143313661126714021032 0ustar liggesusersPNG  IHDRz4iCCPkCGColorSpaceGenericRGB8U]hU>sg#$Sl4t? % V46nI6"dΘ83OEP|1Ŀ (>/ % (>P苦;3ie|{g蹪X-2s=+WQ+]L6O w[C{_F qb Uvz?Zb1@/zcs>~if,ӈUSjF 1_Mjbuݠpamhmçϙ>a\+5%QKFkm}ۖ?ޚD\!~6,-7SثŜvķ5Z;[rmS5{yDyH}r9|-ăFAJjI.[/]mK 7KRDrYQO-Q||6 (0 MXd(@h2_f<:”_δ*d>e\c?~,7?& ك^2Iq2"y@g|U\ @IDATxEͻsF@EQQP̨O _333ݩgVŌ(b@QD= sZ6_o =ټ3LwuwWy竔PjD@D@D@D@D$Q>FD@D@D@D@, P" " " " uJ@Nq+3 P" " " " uJ@Nq+3 (u(^f3x?Ɨ_~ŋ8Ӱ%%%x70sLY){ߎASO9&Mœ9spw⫯”)SC!!!r7buӧ84mƕFڵk+<4{ /0-[_W[,M7݄f͚#33]tQ@vD@D@D@D,q1c0j(Oر#;+z-/͛7裏_+Vm۶V 2O>_~ Loƽ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A󭿜`—WpoxA |]X|־o(@컿Fb`||HHH(G ń@1&Áι!LC~b.l{ζyY~[k% 8 P:i0MqJAdKkfW_}`:Ń+a{<fMd޼y/|A?|9,YG!   P &I ^ `-Lc>쳲n:mҥOK.4czAXK 7l`,uʕM$@$ >''Z@,X`慇ToF@h߼y|S*Ai&?|c @({^9 E`׮]:$W^y]tL0AnzΕ{[nŹYN8ᄣֹB$@$@ @H@yg7xLtbtny'eԩr9Ȳe /?~\s5&{LMG (mF `d;dR^^.EEE3}GKJJHHh|?HHHl1 IHHHh<:HHH"H4yj   GXf     IHHH  PcIHHH (@#&   x$@k&   g-IENDB`covid19us/man/pipe.Rd0000644000176200001440000000040513634322575014110 0ustar liggesusers% Generated by roxygen2: do not edit by hand % Please edit documentation in R/utils-pipe.R \name{\%>\%} \alias{\%>\%} \title{Pipe operator} \usage{ lhs \%>\% rhs } \description{ See \code{magrittr::\link[magrittr:pipe]{\%>\%}} for details. } \keyword{internal} covid19us/man/covid19us-package.Rd0000644000176200001440000000076113635213154016370 0ustar liggesusers% Generated by roxygen2: do not edit by hand % Please edit documentation in R/covid19us-package.R \docType{package} \name{covid19us-package} \alias{covid19us} \alias{covid19us-package} \title{covid19us: Cases of COVID-19 in the United States} \description{ A wrapper around the 'COVID Tracking Project API' providing data on cases of COVID-19 in the US. } \author{ \strong{Maintainer}: Amanda Dobbyn \email{amanda.e.dobbyn@gmail.com} } \keyword{internal} covid19us/man/get_us_current.Rd0000644000176200001440000000054213635213154016176 0ustar liggesusers% Generated by roxygen2: do not edit by hand % Please edit documentation in R/get.R \name{get_us_current} \alias{get_us_current} \title{Get current US counts} \usage{ get_us_current() } \value{ A tibble with one row for the current count of the country's COVID statuses. } \description{ Get current US counts } \examples{ \donttest{ get_us_current() } } covid19us/man/get_counties_info.Rd0000644000176200001440000000072513635213121016646 0ustar liggesusers% Generated by roxygen2: do not edit by hand % Please edit documentation in R/get.R \name{get_counties_info} \alias{get_counties_info} \title{Get COVID-related information for certain counties} \usage{ get_counties_info() } \value{ A tibble with one row per county and their COVID website information. } \description{ Currently limited to the worst-affected counties in mostly Washington state, California, and New York. } \examples{ \donttest{ get_counties_info() } } covid19us/man/get_us_daily.Rd0000644000176200001440000000055613635213154015623 0ustar liggesusers% Generated by roxygen2: do not edit by hand % Please edit documentation in R/get.R \name{get_us_daily} \alias{get_us_daily} \title{Get daily US counts} \usage{ get_us_daily() } \value{ A tibble with one row per date in which data is available and counts for each of those states. } \description{ Updated every day at 4pm. } \examples{ \donttest{ get_us_daily() } } covid19us/DESCRIPTION0000644000176200001440000000167513725357443013634 0ustar liggesusersPackage: covid19us Title: Cases of COVID-19 in the United States Version: 0.1.7 Authors@R: person(given = "Amanda", family = "Dobbyn", role = c("aut", "cre"), email = "amanda.e.dobbyn@gmail.com") Description: A wrapper around the 'COVID Tracking Project API' providing data on cases of COVID-19 in the US. License: MIT + file LICENSE Imports: curl (>= 4.3), dplyr (>= 0.8.3), glue (>= 1.3.1), httr (>= 1.4.1), lubridate (>= 1.7.4), magrittr (>= 1.5), purrr (>= 0.3.3), snakecase (>= 0.11.0), stringr (>= 1.4.0), tibble (>= 2.1.3), tidyr (>= 1.0.2) Suggests: covr (>= 3.4.0), testthat (>= 2.1.0) Encoding: UTF-8 LazyData: true RoxygenNote: 7.1.1 NeedsCompilation: no Packaged: 2020-08-31 15:06:21 UTC; amanda Author: Amanda Dobbyn [aut, cre] Maintainer: Amanda Dobbyn Repository: CRAN Date/Publication: 2020-09-07 07:20:03 UTC covid19us/tests/0000755000176200001440000000000013671265111013245 5ustar liggesuserscovid19us/tests/testthat/0000755000176200001440000000000013725357443015117 5ustar liggesuserscovid19us/tests/testthat/test-all.R0000644000176200001440000000327213653704367016774 0ustar liggesuserstest_that("get_states_daily works", { # Many rows full <- get_states_daily() # One state ct <- get_states_daily("CT") # One one state one date specific <- get_states_daily("NY", "2020-03-17") # Zero rows too_early <- get_states_daily(date = "2019-08-25") if (nrow(full) > 0) expect_gte(ncol(full), 7) if (nrow(ct) > 0) expect_gte(ncol(ct), 7) if (nrow(specific) > 0) expect_gte(ncol(specific), 7) if (nrow(full) > 0) expect_gte(nrow(full), 500) if (nrow(ct) > 0) expect_gte(nrow(ct), 10) if (nrow(specific) > 0) expect_equal(nrow(specific), 1) expect_equal(nrow(too_early), 0) }) test_that("other funs work", { states_current <- get_states_current() if (nrow(states_current) > 0) { expect_is( c( states_current$last_update, states_current$check_time ), "POSIXct" ) } states_info <- get_states_info() if (nrow(states_info) > 0) { expect_gte(ncol(states_info), 6) } us_current <- get_us_current() if (nrow(us_current) > 0) expect_equal(nrow(us_current), 1) us_daily <- get_us_daily() if (nrow(us_daily) > 0) expect_gte(nrow(us_daily), 10) counties_info <- get_counties_info() if (nrow(counties_info) > 0) { expect_gte(length(unique(counties_info$state)), 3) } urls <- get_tracker_urls() if (nrow(urls) > 0) expect_gte(ncol(urls), 5) refresh <- refresh_covid19us() if (nrow(refresh) > 0) expect_gte(ncol(refresh), 5) refresh_names <- c("date", "location", "location_type", "location_code", "location_code_type", "data_type", "value") if (nrow(refresh) > 0) expect_true(all(refresh_names %in% names(refresh))) info <- get_info_covid19us() if (nrow(info) > 0) expect_gte(ncol(info), 5) }) covid19us/tests/testthat.R0000644000176200001440000000007613634673370015244 0ustar liggesuserslibrary(testthat) library(covid19us) test_check("covid19us") covid19us/R/0000755000176200001440000000000013723206145012304 5ustar liggesuserscovid19us/R/covid19us-package.R0000644000176200001440000000015713634647245015664 0ustar liggesusers#' @keywords internal "_PACKAGE" #' @import dplyr ## usethis namespace: start ## usethis namespace: end NULL covid19us/R/utils.R0000644000176200001440000000507113661126714013576 0ustar liggesusersbase_url <- "https://covidtracking.com/api/v1/" request <- function(url) { # nocov start resp <- httr::RETRY("GET", url) status <- httr::status_code(resp) if (status >= 300) { message( glue::glue("API currently unavailable: status code {status}.") ) return(tibble::tibble()) } lst <- httr::content(resp) if (length(lst) == 0) { message("No results for this request.") return(tibble::tibble()) } # Only one result if (length(lst[[1]]) == 1) { tbl <- lst %>% purrr::map(replace_null) %>% tibble::as_tibble() } else { tbl <- lst %>% purrr::modify_depth(2, replace_null) %>% purrr::map(tibble::as_tibble) %>% bind_rows() } tbl %<>% rename_all( snakecase::to_snake_case ) %>% # Remove Eastern Time suffix if it exists rename_all( stringr::str_remove_all, "_et" ) %>% # In case stray spaces get in on some runs and mess with joins on e.g. state abbreviation mutate_if( is.character, stringr::str_squish ) # pos_neg is just the sum of positive and negative so doesn't add much new info suppressWarnings( tbl %<>% select( -one_of("pos_neg") ) ) date_vars <- names(tbl) %>% .[stringr::str_detect(., "date|update|time")] tbl %>% mutate_at( date_vars, clean_date ) %>% mutate( request_datetime = lubridate::now() ) } # nocov end try_request <- purrr::possibly( request, otherwise = tibble(), quiet = FALSE ) get <- function(endpoint, query = "") { url <- glue::glue("{base_url}{endpoint}{query}.json") have_internet <- curl::has_internet() if (!have_internet) { message("No internet connection.") return(tibble()) } try_request(url) } replace_null <- function(x) { if (length(x) == 0) { NA } else { x } } date_to_int <- function(x) { x %>% lubridate::as_date() %>% stringr::str_remove_all("-") %>% as.integer() } clean_date <- function(x) { if (all(stringr::str_detect(x, "[A-Z]+") | is.na(x))) { # For the dateChecked case x %>% stringr::str_remove_all("[A-Z]+") %>% lubridate::as_datetime( tz = "America/New_York" ) } else if (all(stringr::str_detect(x, "/") | is.na(x))) { if (!any(stringr::str_detect(x[!is.na(x)], "/2020"))) { x %<>% stringr::str_replace_all(" ", "/2020 ") } x %>% lubridate::mdy_hm( tz = "America/New_York" ) } else { # For the `date` case in get_states_daily() x %>% lubridate::ymd() } } covid19us/R/globals.R0000644000176200001440000000071013651360045014050 0ustar liggesusers globalVariables( c( ".", "check_time", "data_type", "date_checked", "fips", "get_counties", "get_states_current", "get_states_daily", "get_states_info", "get_tracker_urls", "get_us_current", "get_us_daily", "kind", "last_update", "location_code_type", "location_type", "name", "request_datetime", "ssl_no_verify", "state", "state_name", "states", "value" ) ) covid19us/R/utils-pipe.R0000644000176200001440000000067513634322602014530 0ustar liggesusers#' Pipe operator #' #' See \code{magrittr::\link[magrittr:pipe]{\%>\%}} for details. #' #' @name %>% #' @rdname pipe #' @keywords internal #' @export #' @importFrom magrittr %>% #' @usage lhs \%>\% rhs NULL #' Assignment pipe operator #' #' See \code{magrittr::\link[magrittr:compound]{\%<>\%}} for details. #' #' @name %<>% #' @rdname assignment_pipe #' @keywords internal #' @export #' @importFrom magrittr %<>% #' @usage lhs \%<>\% rhs NULL covid19us/R/get.R0000644000176200001440000001313113723206143013203 0ustar liggesusers#' Get current counts for every state #' #' @return A tibble with one row per state and columns for individuals' COVID statuses (positive, negative, pending, death) and their total. #' @export #' #' @examples #' \donttest{ #' get_states_current() #' } get_states_current <- function() { get("states") } #' Get daily counts for every state #' #' Daily counts are updated every day at 4pm EST. This is the only function that takes arguments. #' #' @param state State abbreviation for a specific state or all states with \code{"all"}. #' @param date For a specific date, a character or date vector of length 1 coercible to a date with \code{lubridate::as_date()}. #' #' @return A tibble with one row per state for all dates available with columns for individuals' COVID statuses (positive, negative, pending, death) and their total. #' @export #' #' @examples #' \donttest{ #' get_states_daily() #' #' get_states_daily("NY", "2020-03-17") #' get_states_daily(state = "WA") #' get_states_daily(date = "2020-03-11") #' } get_states_daily <- function(state = "all", date = "all") { dat <- get("states/daily") if (date != "all") { dt <- clean_date(date) dat %<>% filter( date == dt ) } if (state != "all") { st <- state dat %<>% filter( state == st ) } dat } #' Get COVID-related information for each state #' #' @return A tibble with one row per state incluing information on the state's \code{data_site} where the data was pulled from and the \code{covid_19_site} where data is published. #' @export #' #' @examples #' \donttest{ #' get_states_info() #' } get_states_info <- function() { tbl <- get("states/info") if (nrow(tbl) == 0) { return(tbl) } tbl %>% select( state, name, everything() ) } #' Get current US counts #' #' @return A tibble with one row for the current count of the country's COVID statuses. #' @export #' #' @examples #' \donttest{ #' get_us_current() #' } get_us_current <- function() { get("us") } #' Get daily US counts #' #' Updated every day at 4pm. #' #' @return A tibble with one row per date in which data is available and counts for each of those states. #' @export #' #' @examples #' \donttest{ #' get_us_daily() #' } get_us_daily <- function() { tbl <- get("us/daily") if (nrow(tbl) == 0) { return(tbl) } tbl %>% rename( n_states = states ) %>% arrange( desc(date) ) } data_type_reg <- "death|hospitalized|icu|negative|pending|positive|recovered|total|ventilator" #' Get state data in long format #' #' @param type One of \code{"daily"} or \code{"current"} #' #' @return A tibble of data retrieved with \code{\link{get_states_daily}} or \code{\link{get_states_current}} in long format with a \code{data_type} and a \code{value} column. #' @export #' #' @examples #' \donttest{ #' refresh_covid19us() #' } refresh_covid19us <- function(type = "daily") { stopifnot(type %in% c("daily", "current")) fun <- ifelse(type == "daily", get_states_daily, get_states_current) raw <- fun() if (nrow(raw) == 0) { return(raw) } raw %>% mutate_all(as.character) %>% tidyr::pivot_longer( matches(data_type_reg), names_to = "data_type" ) %>% mutate( date = lubridate::as_date(date), location_type = "state", location_code_type = "fips_code" ) %>% select( date, location = state, location_type, location_code = fips, location_code_type, data_type, value ) } #' Get info about this dataset #' #' @return A tibble with information about where the data is pulled from, details about the dataset, what the data types are, etc. #' @export #' #' @examples #' \donttest{ #' get_info_covid19us() #' } get_info_covid19us <- function() { latest_data <- refresh_covid19us(type = "daily") dplyr::tibble( data_set_name = "covid19us", package_name = "covid19us", function_to_get_data = "refresh_covid19us", data_details = "Open Source data from COVID Tracking Project on the distribution of Covid-19 cases and deaths in the US. For more, see https://github.com/opencovid19-fr/data.", data_url = "https://covidtracking.com/api", license_url = "https://github.com/aedobbyn/covid19us/blob/master/LICENSE.md", data_types = latest_data %>% tidyr::drop_na(data_type) %>% dplyr::pull(data_type) %>% unique() %>% stringr::str_c(collapse = ", "), location_types = latest_data %>% tidyr::drop_na(location_type) %>% dplyr::pull(location_type) %>% unique() %>% stringr::str_c(collapse = ", "), spatial_extent = "country", has_geospatial_info = FALSE ) } #' Get COVID-related information for certain counties #' #' Currently limited to the worst-affected counties in mostly Washington state, California, and New York. #' #' @return A tibble with one row per county and their COVID website information. #' @export #' #' @examples #' \donttest{ #' get_counties_info() #' } get_counties_info <- function() { get("counties") } #' Get URLs and their details for each state #' #' @return A tibble with one row for every state, the URL used by scrapers to get data, and a \code{filter} column that provices the xpath or CSS selector used by the \href{https://github.com/COVID19Tracking/covid-tracking}{COVID-19 Tracking Project's scraper} to get this data. #' @export #' #' @examples #' \donttest{ #' get_tracker_urls() #' } get_tracker_urls <- function() { tbl <- get("urls") if (nrow(tbl) == 0) { return(tbl) } tbl %>% rename( state_name = name ) %>% select( state_name, url, filter, ssl_no_verify, kind, request_datetime ) } covid19us/MD50000644000176200001440000000240213725357443012423 0ustar liggesusers23e14b0662d62bae02dfebb03c70ba22 *DESCRIPTION bb1a9eab349e38666cc71db9e60c0f65 *LICENSE 8534bc3f2d124e841d6a1c1284fe373f *NAMESPACE 4371445afd150938dfee96e958516c94 *R/covid19us-package.R e2d10802e6312c59d3fbfb8f840e3d88 *R/get.R 14595ea7cc710b5d9c0be3095b7a9e5b *R/globals.R 443567bc6b69538564cfc1405aaf2ee6 *R/utils-pipe.R ebe7aeb33304ab26f9ce555a76e987d2 *R/utils.R 8a74bd89a3f8e396bb6efd6724ba0010 *README.md 9f366151887ee038c26db3aaec4b438c *man/assignment_pipe.Rd 3553866e647854a3767b863171421392 *man/covid19us-package.Rd 7bf83f17ffaa169511d9df1217290014 *man/figures/README-unnamed-chunk-6-1.png 07670a4ff4d92f6acd2f90638d0308f2 *man/get_counties_info.Rd a83c37819c09d81514b308fd063d30da *man/get_info_covid19us.Rd 33a72065f92762b71f6f8fc39d2e5399 *man/get_states_current.Rd 488665bec0c4116b74cd562e743dc3fe *man/get_states_daily.Rd 671a1b640235c86abb06766d17812b04 *man/get_states_info.Rd dd419b673753ac46334f31aeb11417d9 *man/get_tracker_urls.Rd 95f6434188b5852cb0f4ee4268f29211 *man/get_us_current.Rd 5ded662d1010e93984984df578d3ffc8 *man/get_us_daily.Rd 4894ca10756199e25f914bfd34f517b0 *man/pipe.Rd fd92a4442b2c01f48b2aafab128c2e96 *man/refresh_covid19us.Rd f4b62fd8f49b5c951edfcca1147ffabc *tests/testthat.R 349b16234d0bdb15b090bfd87e5db84c *tests/testthat/test-all.R