Resolves a CIHI table from the bundled catalogue and downloads it to
dest, falling back to the Internet Archive snapshot if the live
CIHI URL has rotated or been removed. The download + fallback runs
through rmoriebricklayer's shared C++/libcurl foundation
(blfetch()).
Arguments
- which
A row index into
cihitbls(), or a string matched (case-insensitively, as a substring) against table titles. Must resolve to exactly one table.- dest
Destination file path. Default: a tempfile with the table's own extension.
- timeout
Per-request timeout in seconds, from 1 to 86400 (a day); a fraction is rounded up to the next whole second.
Examples
# Offline: inspect the catalogue to choose a `which` argument.
cat <- cihitbls()
head(cat$title, 3)
#> [1] "Injury and Trauma Emergency Department and Hospitalization Statistics, 2024–2025"
#> [2] "Wait Times for Priority Procedures in Canada, 2008 to 2025 — Data Tables"
#> [3] "Health Workforce in Canada, 2024 — Quick Stats"
# \donttest{
# Downloads a table from the live CIHI web service; try() keeps the
# example graceful when the service is unreachable.
# `which` by title substring (case-insensitive; must match exactly one).
f1 <- try(cihiget("Hospital Beds, 2024")) # -> tempfile path
# `which` by row index into cihitbls(); `dest` chooses the
# output path and `timeout` bounds each request (seconds).
f3 <- try(cihiget(1,
dest = tempfile(fileext = ".xlsx"),
timeout = 60
))
# An ambiguous substring errors and lists the candidates:
try(cihiget("data"))
#> Error : 'data' matches 134 tables; be more specific:
#> Wait Times for Priority Procedures in Canada, 2008 to 2025 — Data Tables
#> Formulary Coverage in the Pharmaceutical Data Tool
#> How Canada Compares: Results From the Commonwealth Fund’s 2025 International Health Policy Survey of Primary Care Physicians in 10 Countries — Data Tables
#> NACRS Emergency Department Visits and Lengths of Stay by Province/Territory, 2025–2026 (Q1 to Q2) — Provisional Data
#> Deceased Donation, Living Donation and Transplantation in Canada: Summary Volumes — Data Tables
#> Adult Organ Donation and Transplantation, 2015 to 2024 — Supplementary Data Tables
# }
