Title: | Client for Statistics Canada's Open Economic Data |
---|---|
Description: | An easy connection with R to Statistics Canada's Web Data Service. Open economic data (formerly known as CANSIM tables, now identified by Product IDs (PID)) are accessible as a data frame, directly in the user's R environment. Warin, Le Duc (2019) <doi:10.6084/m9.figshare.10544735>. |
Authors: | Thierry Warin [aut, cre] |
Maintainer: | Thierry Warin <[email protected]> |
License: | MIT + file LICENSE |
Version: | 0.2.9000 |
Built: | 2025-02-11 05:13:37 UTC |
Source: | https://github.com/warint/statcanr |
Easily connect to Statistics Canada's Web Data Service with R. Open economic data (formerly known as CANSIM tables, now identified by Product IDs (PID)) are accessible as a data frame, directly in the user's R environment.
statcan_data(tableNumber, lang)
statcan_data(tableNumber, lang)
tableNumber |
The table number of the Statistics Canada data table |
lang |
The language wanted |
The
statcan_data()
function has 2 arguments to fulfill to get data: tableNumber & lang.
The tableNumber argument simply refers to the table number of the Statistics Canada data table a user wants to collect, such as '27-10-0014-01' for the Federal expenditures on science and technology, by socio-economic objectives, as an example.
To get the table number: https://www150.statcan.gc.ca/n1/en/type/data.
The second argument, lang, refers to the language. As Canada is a bilingual country, Statistics Canada displays all the economic data in both languages. Therefore, users can choose to collect satistics data tables in French or English by setting the lang argument with c('fra', 'eng').
The output will be a data table representing the data associated with the chosen table number.
#mydata <- statcan_data('27-10-0014-01', 'eng')
#mydata <- statcan_data('27-10-0014-01', 'eng')
statcanR download data function
statcan_download_data(tableNumber, lang)
statcan_download_data(tableNumber, lang)
tableNumber |
The table number of the Statistics Canada data table |
lang |
The language wanted |
The output will be a data table and csv file representing the data associated with the chosen table number.
mydata <- statcan_data('27-10-0014-01', 'eng')
mydata <- statcan_data('27-10-0014-01', 'eng')
The statcan_search()
function has 2 arguments to fulfill to find a database: keywords and lang.
The keywords argument refers to words that can be found in either the title or the description of the database. For example, inserting the keywords
"economy","export",and "link" will bring up the title, table id, description, and release date for databases that include these keywords. In this case, only one data table ("Supply and use tables, link-1997 level")
would be returned as it is the only data table containing all three words.
statcan_search(keywords, lang)
statcan_search(keywords, lang)
keywords |
The words that appear in the title or description of the data table |
lang |
The language wanted |
Easily connect to Statistics Canada's Web Data Service with R. Open economic data (formerly known as CANSIM tables, now identified by Product IDs (PID)) are accessible as a data frame, directly in the user's R environment.
The output will be the title, id, description, and release date of a table
statcan_search(c("economy","export","link"),"eng")
statcan_search(c("economy","export","link"),"eng")