Allows for the retrieval of data for specified vector series for the N most-recently released periods.
Accessing data by vector allows for targeted extraction of time series. Discovering vectors of interest can be achieved
using the StatCan table web interface or using get_cansim_table_template
function to help pinpoint data series of interest, and then chaining the add_cansim_vectors_to_template
function to add
cansim vector information to the template data.
The StatCan API can only process 300 coordinates at a time,
if more than 300 coordinates are specified the function will batch the requests to the API.
get_cansim_vector_for_latest_periods(
vectors,
periods = NULL,
language = "english",
refresh = FALSE,
timeout = 200,
factors = TRUE,
default_month = "07",
default_day = "01"
)
A tibble with data for specified vector(s) for the last N periods
The list of vectors to retrieve
Numeric value for number of latest periods to retrieve data for, but default all data is retrieved.
"en"
or "english"
for English and "fr"
or "french"
for French language versions (defaults to English)
(Optional) When set to TRUE
, forces a reload of data table (default is FALSE
)
(Optional) Timeout in seconds for downloading cansim table to work around scenarios where StatCan servers drop the network connection.
(Optional) Logical value indicating if dimensions should be converted to factors. (Default set to TRUE
).
The default month that should be used when creating Date objects for annual data (default set to "07")
The default day of the month that should be used when creating Date objects for monthly data (default set to "01")
if (FALSE) {
get_cansim_vector_for_latest_periods("v41690973",10)
}
Run the code above in your browser using DataLab