View source: R/cansim_vectors.R
| get_cansim_vector | R Documentation |
Allows for the retrieval of data for specified vector series for a given time window.
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(
vectors,
start_time = as.Date("1800-01-01"),
end_time = Sys.time(),
use_ref_date = TRUE,
language = "english",
refresh = FALSE,
timeout = 200,
factors = TRUE,
default_month = "07",
default_day = "01"
)
vectors |
The list of vectors to retrieve |
start_time |
Starting date in |
end_time |
Set an optional end time filter in |
use_ref_date |
Optional, |
language |
|
refresh |
(Optional) When set to |
timeout |
(Optional) Number of seconds StatCan is allowed to go without sending data before the download is abandoned, to work around scenarios where StatCan servers drop the network connection. This does not limit how long a download may take overall, a transfer that keeps delivering data is left alone. StatCan prepares a whole response before sending any of it, which for large requests can take the better part of a minute, so values much below the default of 200 risk cutting off legitimate requests. |
factors |
(Optional) Logical value indicating if dimensions should be converted to factors. (Default set to |
default_month |
The default month that should be used when creating Date objects for annual data (default set to "07") |
default_day |
The default day of the month that should be used when creating Date objects for monthly data (default set to "01") |
A tibble with data for vectors released between start and end time
Returns NULL if the data could not be retrieved because StatCan is unavailable.
get_cansim_vector("v41690973","2015-01-01")
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.