MyNixOS website logo
Description

Client for Statistics Canada's Open Economic Data.

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>.

statcanR

Travis buildstatus AppVeyor buildstatus Mentioned inAwesome CRANstatus

Overview

Easily connect to Statistics Canada’s Web Data Service with R. Find and access open economic data (formerly known as CANSIM tables, now identified by Product IDs (PID)) which are accessible as a data frame, directly in the user’s R environment.

Shiny App : statcanR ExploR

For people less comfortable with R and to allow more people to have access to our package, we have also developed a Shiny application.Through the same logic present in our package, researchers can retrieve data from Statistics Canada.

statcanR EploR is available [here]

Installation

The released version of statcanR package is accessible through CRAN and devtools.

install.packages("statcanR")

install.packages("devtools")
devtools::install_github('warint/statcanR')

Example

This section presents an example of how to use the statcanR R package and its functions: statcan_search(), statcan_data(), and statcan_download_data().

The following example is provided to illustrate how to use the functions. It consists in collecting some descriptive statistics about the Canadian Labour Force at the federal, provincial and industrial levels, on a monthly basis.

To identify a relevant table, the statcan_search() function can be used by using a keyword or set of keywords and specifying the language in which the data will be presented (English or French). Below is an example that reveals the data tables we could be interested in:

library(statcanR)
statcan_search(c("federal","expenditures","objectives"),"eng")

Notice that for each corresponding table, the unique table number identifier is also presented. Let's focus the first table out of the two that appear, which contains data on Federal expenditures on science and technology, by socio-economic objectives. Once this table number is identified (‘27-10-0014-01’), the statcan_data() function is easy to use in order to collect the data, as following:

library(statcanR)
mydata <- statcan_data("27-10-0014-01","eng")

For the statcan_download_data() function there is no difference on how to use it, the only difference is that this function allow you to download the data in a csv file on top of having the data in your environment.

library(statcanR)
mydata <- statcan_download_data("27-10-0014-01","eng")

Video Tutorial

Tutorial made by Professor Charles Saunders, Director of Master of Financial Economics Program at Western University biography

Thanks!

https://www.youtube.com/embed/z9TDUlgT5lc

Statistics Canada Open Licence

This licence is issued on behalf of His Majesty the King in Right of Canada, as represented by the Minister for Statistics Canada (“Statistics Canada”) to you (an individual or a legal entity that you are authorized to represent).

Statistics Canada may modify this licence at any time, and such modifications shall be effective immediately upon posting of the modified licence on the Statistics Canada website. Your use of the Information will be governed by the terms of the licence in force as of the date and time you accessed the Information.

Please refer to the terms of licence before using the Information.

Acknowledgment of Source according to Statistics Canada Open Licence Agreement

Statistics Canada has a specific procedure regarding the acknowledgment of source :

You shall include and maintain the following notice on all licensed rights of the Information:

Source: Statistics Canada, name of product, reference date. Reproduced and distributed on an "as is" basis with the permission of Statistics Canada.

Where any Information is contained within a Value-added Product, you shall include on such Value-added Product the following notice:

Adapted from Statistics Canada, name of product, reference date. This does not constitute an endorsement by Statistics Canada of this product.

Cite statcanR

To cite statcanR package in your work:

Warin, T. (2023). statcanR: Client for Statistics Canada’s Open Economic Data. v0.2.4.

@Manual{R-statcanR,
   title = {statcanR: Client for Statistics Canada's Open Economic Data},
   author = {Thierry Warin},
   note = {R package version 0.2.4},
   url = {https://github.com/warint/statcanR},
   year = {2023}"
 }

Acknowledgments

The author would like to thank the Center for Interuniversity Research and Analysis of Organizations (CIRANO, Montreal) for its support, as well as Thibault Senegas, Jeremy Schneider, Marine Leroi, Martin Paquette and Romain Le Duc. However, errors and omissions are his.

Metadata

Version

0.2.6

License

Unknown

Platforms (75)

    Darwin
    FreeBSD
    Genode
    GHCJS
    Linux
    MMIXware
    NetBSD
    none
    OpenBSD
    Redox
    Solaris
    WASI
    Windows
Show all
  • aarch64-darwin
  • aarch64-genode
  • aarch64-linux
  • aarch64-netbsd
  • aarch64-none
  • aarch64_be-none
  • arm-none
  • armv5tel-linux
  • armv6l-linux
  • armv6l-netbsd
  • armv6l-none
  • armv7a-darwin
  • armv7a-linux
  • armv7a-netbsd
  • armv7l-linux
  • armv7l-netbsd
  • avr-none
  • i686-cygwin
  • i686-darwin
  • i686-freebsd
  • i686-genode
  • i686-linux
  • i686-netbsd
  • i686-none
  • i686-openbsd
  • i686-windows
  • javascript-ghcjs
  • loongarch64-linux
  • m68k-linux
  • m68k-netbsd
  • m68k-none
  • microblaze-linux
  • microblaze-none
  • microblazeel-linux
  • microblazeel-none
  • mips-linux
  • mips-none
  • mips64-linux
  • mips64-none
  • mips64el-linux
  • mipsel-linux
  • mipsel-netbsd
  • mmix-mmixware
  • msp430-none
  • or1k-none
  • powerpc-netbsd
  • powerpc-none
  • powerpc64-linux
  • powerpc64le-linux
  • powerpcle-none
  • riscv32-linux
  • riscv32-netbsd
  • riscv32-none
  • riscv64-linux
  • riscv64-netbsd
  • riscv64-none
  • rx-none
  • s390-linux
  • s390-none
  • s390x-linux
  • s390x-none
  • vc4-none
  • wasm32-wasi
  • wasm64-wasi
  • x86_64-cygwin
  • x86_64-darwin
  • x86_64-freebsd
  • x86_64-genode
  • x86_64-linux
  • x86_64-netbsd
  • x86_64-none
  • x86_64-openbsd
  • x86_64-redox
  • x86_64-solaris
  • x86_64-windows