Runs a GET request of reports data from the COVID-19 tracker API, and
returns parsed data.
Via the split
argument, data may be "overall" (all provinces/territories
combined), or by "province".
Alternatively, provide one or more two-letter codes (e.g. "AB") to province
to return reports for specific provinces, or one or more numeric region
codes (e.g. "1204") to return specific health regions.
Usage
get_reports(
split = c("overall", "province"),
province = NULL,
region = NULL,
fill_dates = NULL,
stat = NULL,
date = NULL,
after = NULL,
before = NULL
)
Arguments
- split
One of "overall", or "province" to specify how the data is split. An "overall" report gives cumulative numbers across Canada. Splitting by "province" returns all reports for all provinces/territories.
- province
One or more province/territory codes ("AB", "BC", "MB", "NB", "NL", "NS", "NT", "NU", "ON", "PE", "QC", "SK", "YT") to get reports. Upper, lower and mixed case strings are accepted.
- region
One or more health region IDs to get reports. Numeric and character values are accepted.
- fill_dates
When TRUE, the response fills in any missing dates with blank entries.
- stat
Returns only the specified statistics, e.g. "cases".
- date
Returns reports from only the specified date, in YYYY-MM-DD format.
- after
Returns reports from only on or after the specified date, in YYYY-MM-DD format.
- before
Returns reports from only on or before the specified date, in YYYY-MM-DD format.
Value
A data frame containing the reports data, one row per day. Includes
a province
variable if data is split by province, and a hr_uid
variable
if data is split by health region.
Examples
get_reports()
#> # A tibble: 938 × 24
#> last_updated date change_cases change_…¹ chang…² chang…³ chang…⁴
#> <dttm> <date> <int> <int> <int> <int> <int>
#> 1 2022-08-22 04:23:04 2020-01-25 1 0 2 0 0
#> 2 2022-08-22 04:23:04 2020-01-26 1 0 4 0 0
#> 3 2022-08-22 04:23:04 2020-01-27 0 0 20 0 0
#> 4 2022-08-22 04:23:04 2020-01-28 1 0 10 0 0
#> 5 2022-08-22 04:23:04 2020-01-29 0 0 3 0 0
#> 6 2022-08-22 04:23:04 2020-01-30 0 0 26 0 0
#> 7 2022-08-22 04:23:04 2020-01-31 1 0 33 0 0
#> 8 2022-08-22 04:23:04 2020-02-01 0 0 23 0 0
#> 9 2022-08-22 04:23:04 2020-02-02 0 0 24 0 0
#> 10 2022-08-22 04:23:04 2020-02-03 0 0 16 0 0
#> # … with 928 more rows, 17 more variables: change_recoveries <int>,
#> # change_vaccinations <int>, change_vaccinated <int>,
#> # change_boosters_1 <int>, change_boosters_2 <int>,
#> # change_vaccines_distributed <int>, total_cases <int>,
#> # total_fatalities <int>, total_tests <int>, total_hospitalizations <int>,
#> # total_criticals <int>, total_recoveries <int>, total_vaccinations <int>,
#> # total_vaccinated <int>, total_boosters_1 <int>, total_boosters_2 <int>, …
get_reports(province = c("AB", "SK"))
#> # A tibble: 1,874 × 25
#> province last_updated date change_cases change…¹ chang…² chang…³
#> <chr> <dttm> <date> <int> <int> <int> <int>
#> 1 AB 2022-08-21 20:15:30 2020-01-25 0 0 0 0
#> 2 AB 2022-08-21 20:15:30 2020-01-26 0 0 0 0
#> 3 AB 2022-08-21 20:15:30 2020-01-27 0 0 0 0
#> 4 AB 2022-08-21 20:15:30 2020-01-28 0 0 0 0
#> 5 AB 2022-08-21 20:15:30 2020-01-29 0 0 0 0
#> 6 AB 2022-08-21 20:15:30 2020-01-30 0 0 0 0
#> 7 AB 2022-08-21 20:15:30 2020-01-31 0 0 0 0
#> 8 AB 2022-08-21 20:15:30 2020-02-01 0 0 0 0
#> 9 AB 2022-08-21 20:15:30 2020-02-02 0 0 0 0
#> 10 AB 2022-08-21 20:15:30 2020-02-03 0 0 0 0
#> # … with 1,864 more rows, 18 more variables: change_criticals <int>,
#> # change_recoveries <int>, change_vaccinations <int>,
#> # change_vaccinated <int>, change_boosters_1 <int>, change_boosters_2 <int>,
#> # change_vaccines_distributed <int>, total_cases <int>,
#> # total_fatalities <int>, total_tests <int>, total_hospitalizations <int>,
#> # total_criticals <int>, total_recoveries <int>, total_vaccinations <int>,
#> # total_vaccinated <int>, total_boosters_1 <int>, total_boosters_2 <int>, …
get_reports(region = 1204)
#> # A tibble: 856 × 9
#> hr_uid last_updated date chang…¹ chang…² total…³ total…⁴ chang…⁵
#> <int> <dttm> <date> <int> <int> <int> <int> <int>
#> 1 1204 2022-08-22 04:23:04 2020-01-15 0 0 0 0 NA
#> 2 1204 2022-08-22 04:23:04 2020-01-16 0 0 0 0 NA
#> 3 1204 2022-08-22 04:23:04 2020-01-17 0 0 0 0 NA
#> 4 1204 2022-08-22 04:23:04 2020-01-18 0 0 0 0 NA
#> 5 1204 2022-08-22 04:23:04 2020-01-19 0 0 0 0 NA
#> 6 1204 2022-08-22 04:23:04 2020-01-20 0 0 0 0 NA
#> 7 1204 2022-08-22 04:23:04 2020-01-21 0 0 0 0 NA
#> 8 1204 2022-08-22 04:23:04 2020-01-22 0 0 0 0 NA
#> 9 1204 2022-08-22 04:23:04 2020-01-23 0 0 0 0 NA
#> 10 1204 2022-08-22 04:23:04 2020-01-24 0 0 0 0 NA
#> # … with 846 more rows, 1 more variable: total_recoveries <int>, and
#> # abbreviated variable names ¹change_cases, ²change_fatalities, ³total_cases,
#> # ⁴total_fatalities, ⁵change_recoveries
get_reports(region = c("472", 1204), stat = "cases")
#> # A tibble: 1,710 × 5
#> hr_uid last_updated date change_cases total_cases
#> <int> <dttm> <date> <int> <int>
#> 1 472 2022-08-22 04:23:04 2020-01-15 0 0
#> 2 472 2022-08-22 04:23:04 2020-01-16 0 0
#> 3 472 2022-08-22 04:23:04 2020-01-17 0 0
#> 4 472 2022-08-22 04:23:04 2020-01-18 0 0
#> 5 472 2022-08-22 04:23:04 2020-01-19 0 0
#> 6 472 2022-08-22 04:23:04 2020-01-20 0 0
#> 7 472 2022-08-22 04:23:04 2020-01-21 0 0
#> 8 472 2022-08-22 04:23:04 2020-01-22 0 0
#> 9 472 2022-08-22 04:23:04 2020-01-23 0 0
#> 10 472 2022-08-22 04:23:04 2020-01-24 0 0
#> # … with 1,700 more rows