Type: | Package |
Title: | Client for Statistics Canada's Open Economic Data |
Version: | 0.2.6 |
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>. |
License: | MIT + file LICENSE |
Encoding: | UTF-8 |
RoxygenNote: | 7.2.3 |
Suggests: | knitr, rmarkdown, testthat (≥ 3.0.0) |
VignetteBuilder: | knitr |
Imports: | data.table, dplyr, ggplot2, reshape2, qs, qpdf, DT, curl, httr, readr, tibble |
URL: | https://github.com/warint/statcanR/ |
BugReports: | https://github.com/warint/statcanR/issues/ |
Config/testthat/edition: | 3 |
NeedsCompilation: | no |
Packaged: | 2023-08-16 20:56:13 UTC; warint_github |
Author: | Thierry Warin |
Maintainer: | Thierry Warin <thierry.warin@hec.ca> |
Repository: | CRAN |
Date/Publication: | 2023-08-17 13:50:02 UTC |
statcanR
Description
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.
Usage
statcan_data(tableNumber, lang)
Arguments
tableNumber |
The table number of the Statistics Canada data table |
lang |
The language wanted |
Details
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').
Value
The output will be a data table representing the data associated with the chosen table number.
Examples
#mydata <- statcan_data('27-10-0014-01', 'eng')
statcanR download data function
Description
statcanR download data function
Usage
statcan_download_data(tableNumber, lang)
Arguments
tableNumber |
The table number of the Statistics Canada data table |
lang |
The language wanted |
Value
The output will be a data table and csv file representing the data associated with the chosen table number.
Examples
mydata <- statcan_data('27-10-0014-01', 'eng')
Searching function for statcanR
Description
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.
Usage
statcan_search(keywords, lang)
Arguments
keywords |
The words that appear in the title or description of the data table |
lang |
The language wanted |
Details
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.
Value
The output will be the title, id, description, and release date of a table
Examples
statcan_search(c("economy","export","link"),"eng")