Facilitates working with Statistics Canada data table values retrieved using the package by setting all units to counts/dollars instead of millions, etc. If "replacement_value" is not set, it will replace the VALUE field with normalized values and drop the scale column. Otherwise it will keep the scale columns and create a new column named replacement_value with the normalized value. It will attempt to parse the REF_DATE field and create an R date variable. This is currently experimental.

normalize_cansim_values(
  data,
  replacement_value = NA,
  normalize_percent = TRUE,
  default_month = "01",
  default_day = "01",
  factors = FALSE,
  strip_classification_code = FALSE,
  cansimTableNumber = NULL
)

Arguments

data

A retrieved data table as returned from get_cansim() pr get_cansim_ndm()

replacement_value

(Optional) the name of the column the manipulated value should be returned in. Defaults to replacing the current value field

normalize_percent

(Optional) When true (the default) normalizes percentages by changing them to rates

default_month

The default month that should be used when creating Date objects for annual data (default set to "01")

default_day

The default day of the month that should be used when creating Date objects for monthly data (default set to "01")

factors

(Optional) Logical value indicating if dimensions should be converted to factors. (Default set to false).

strip_classification_code

(strip_classification_code) Logical value indicating if classification code should be stripped from names. (Default set to false).

cansimTableNumber

(Optional) Only needed when operating on results of SQLite connections.

Value

Returns the input tibble with with adjusted values

Examples

if (FALSE) {
cansim_table <- get_cansim("34-10-0013")
normalize_cansim_values(cansim_table)
}