cihiget: Download a CIHI data table (live, with Wayback fallback)

View source: R/load_cihi.R

cihigetR Documentation

Download a CIHI data table (live, with Wayback fallback)

Description

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()), the same engine rmorie and morie use – one implementation across the ecosystem.

Usage

cihiget(which, dest = NULL, timeout = 120L)

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, seconds.

Value

The dest path, invisibly. Errors if both the live URL and its Wayback fallback fail.

Examples

# Offline: inspect the catalogue to choose a `which` argument.
cat <- cihitbls()
head(cat$title, 3)


# 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"))


rmoriedata documentation built on Nov. 12, 2026, 9:06 a.m.