Package 'CANSIM2R'

Title: Directly Extracts Complete CANSIM Data Tables
Description: Extract CANSIM (Statistics Canada) tables and transform them into readily usable data in panel (wide) format. It can also extract more than one table at a time and produce the resulting merge by time period and geographical region.
Authors: Marco Lugo <[email protected]>
Maintainer: Marco Lugo <[email protected]>
License: GPL-3
Version: 1.14.1
Built: 2024-10-31 06:42:18 UTC
Source: CRAN

Help Index


getCANSIM

Description

Extracts a complete CANSIM (Statistics Canada) data table and converts it into a readily usable panel (wide) format.

Usage

getCANSIM(cansimTableNumber='', showLabels = TRUE, raw = FALSE, lang = 'eng')

Arguments

cansimTableNumber

- the table number we wish to retrieve from CANSIM.

showLabels

- show the Statistics Canada labels after finishing extracting and converting the table, TRUE by default.

raw

- download the CANSIM table as-is, skipping all processing, FALSE by default.

lang

- language for data labels ('eng' for English or 'fra' for French), 'eng' by default.

Details

Geographic variables are renamed i, time variables are renamed t, and all the other variables are renamed with a generic V1, V2, ..., Vn. The generic variables keep the full Statistics Canada description by using a label.

Value

data frame containing CANSIM table.

Examples

getCANSIM("12-10-0005")
getCANSIM("12-10-0005", lang = 'fra')

mergeCANSIM

Description

Extracts more than one CANSIM table and produces a merged table (by ID and period).

Usage

mergeCANSIM(cansimTableVector, keepUnmatched = FALSE, showLabels = TRUE, lang = 'eng')

Arguments

cansimTableVector

- vector containing all the CANSIM tables to extract and merge.

keepUnmatched

- if true, keeps all values, even if no match was found. FALSE by default.

showLabels

- show the Statistics Canada labels after finishing extracting and converting the table, TRUE by default.

lang

- language for data labels ('eng' for English or 'fra' for French), 'eng' by default.

Value

data frame containing CANSIM tables.

Examples

mergeCANSIM( c(23100067, 23100238) )

searchLabels

Description

Helper function to search through the Hmisc labels in order to obtain the variable name mapping to their respective labels. It can be particularly useful for bigger datasets for which manual exploration and visualization can be prohibitive.

Usage

searchLabels(df, pattern)

Arguments

df

- data.frame obtained using the getCANSIM function.

pattern

- the string to search for in the variable labels.

Details

Search is case insensitive.

Examples

df <- getCANSIM("12-10-0005")
  searchLabels(df, "imports")