get_cansim_sqlite: Retrieve a Statistics Canada data table using NDM catalogue number as SQLite database connection
Description
Retrieves a data table using an NDM catalogue number as an SQLite table. Retrieved table data is
cached permanently if a chache path is supplied or for duration of the current R session.
This function is useful for large tables that don't have very often.
Usage
get_cansim_sqlite(
cansimTableNumber,
language = "english",
refresh = FALSE,
timeout = 1000,
cache_path = getOption("cansim.cache_path")
)
Arguments
cansimTableNumber
the NDM table number to load
language
"en"
or "english"
for English and "fr"
or "french"
for French language versions (defaults to English)
refresh
(Optional) When set to TRUE
, forces a reload of data table (default is FALSE
)
timeout
(Optional) Timeout in seconds for downloading cansim table to work around scenarios where StatCan servers drop the network connection.
cache_path
(Optional) Path to where to cache the table permanently. By default, the data is cached
in the path specified by `getOption("cansim.cache_path")`, if this is set. Otherwise it will use `tempdir()`.
Value
tibble format data table output with added Date column with inferred date objects and
a "val_norm" column with normalized VALUE using the supplied scale factor
Examples
Run this code# NOT RUN {
con <- get_cansim_sqlite("34-10-0013")
# Work with the data connection
head(con)
disconnect_cansim_sqlite(con)
# }
Run the code above in your browser using DataLab