View source: R/expand_classification.R
expand_classification | R Documentation |
Expand a character representation of a hierarchical classification to make a price index aggregation structure. Expanded classifications be interacted together to get all combinations of aggregation structures.
expand_classification(x, width = 1L)
interact_classifications(..., sep = ":")
x |
A character vector, or something that can be coerced into one, of codes/labels for a specific level in a classification (e.g., 5-digit COICOP, 5-digit NAICS, 4-digit SIC). |
width |
An integer vector that gives the width of each digit in
|
... |
Lists of character vectors that give the codes/labels for each
level of the classification, ordered so that moving down the list goes down
the hierarchy (as made by |
sep |
A character used to combine codes/labels across elements of |
expand_classification()
returns a list with a entry for each level
in x
giving the "digits" that represent each level in the hierarchy.
interact_classfications()
returns a list of lists with the same structure
as expand_classification()
.
aggregation_structure()
to make a price-index aggregation structure.
split_classification()
to expand a classification by splitting along
a delimiter.
# A simple classification structure
# 1
# |-----+-----|
# 11 12
# |---+---| |
# 111 112 121
expand_classification(c("111", "112", "121"))
# Expanding more complex classifications
# ... if last 'digit' is either TA or TS
expand_classification(
c("111TA", "112TA", "121TS"),
width = c(1, 1, 1, 2)
)
# ... if first 'digit' is either 11 or 12
expand_classification(c("111", "112", "121"), width = c(2, 1))
# ...if there are delimiters in the classification (like COICOP)
expand_classification(c("01.1.1", "01.1.2", "01.2.1"), width = 2)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.