concord_naics_bec: Converting NAICS and BEC Codes

concord_naics_becR Documentation

Converting NAICS and BEC Codes

Description

Concords North American Industry Classification System codes (NAICS2002, NAICS2007, NAICS2012, NAICS2017, NAICS combined) to and from Broad Economic Classification codes (BEC Revision 4) via the bridge of Harmonized System codes.

Usage

concord_naics_bec(sourcevar, origin, destination, dest.digit = 2, all = FALSE)

Arguments

sourcevar

An input character vector of NAICS or BEC codes. The function accepts 2 to 6-digit codes for NAICS and 1 to 3-digit codes for BEC.

origin

A string setting the input industry classification: "NAICS2002", "NAICS2007", "NAICS2012", "NAICS2017", "NAICS" (combined), "BEC4" (2016).

destination

A string setting the output industry classification: "NAICS2002", "NAICS2007", "NAICS2012", "NAICS2017", "NAICS" (combined), "BEC4" (2016).

dest.digit

An integer indicating the preferred number of digits for output codes. Allows 2 to 6 digits for NAICS and 1 to 3 digits for BEC codes. The default is 2 digits.

all

Either TRUE or FALSE. If TRUE, the function will return (1) all matched outputs for each input, and (2) the share of occurrences for each matched output among all matched outputs. Users can use the shares as weights for more precise concordances. If FALSE, the function will only return the matched output with the largest share of occurrences (the mode match). If the mode consists of multiple matches, the function will return the first matched output.

Value

The matched output(s) for each element of the input vector. Either a list object when all = TRUE or a character vector when all = FALSE.

Source

Concordance tables provided by:

  • United Nations Trade Statistics <https://unstats.un.org/unsd/trade/classifications/correspondence-tables.asp>

Examples

# one input: one-to-one match
concord_naics_bec(sourcevar = "11111",
                  origin = "NAICS2002", destination = "BEC4",
                  dest.digit = 2, all = FALSE)

concord_naics_bec(sourcevar = "212325",
                  origin = "NAICS2002", destination = "BEC4",
                  dest.digit = 2, all = TRUE)

# two inputs: multiple-to-multiple match
concord_naics_bec(sourcevar = c("11291", "31511"),
                  origin = "NAICS2002", destination = "BEC4",
                  dest.digit = 2, all = FALSE)

concord_naics_bec(sourcevar = c("11291", "31511"),
                  origin = "NAICS2002", destination = "BEC4",
                  dest.digit = 2, all = TRUE)

# repeated inputs
concord_naics_bec(sourcevar = c("11251", "11251"),
                  origin = "NAICS2002", destination = "BEC4",
                  dest.digit = 2, all = FALSE)

# if no match, will return NA and give warning message
concord_naics_bec(sourcevar = c("23721", "23721"),
                  origin = "NAICS2002", destination = "BEC4",
                  dest.digit = 2, all = FALSE)

# 4-digit inputs, 1-digit outputs
concord_naics_bec(sourcevar = c("1129", "3151"),
                  origin = "NAICS2002", destination = "BEC4",
                  dest.digit = 1, all = TRUE)

# BEC4 to NAICS2002
concord_naics_bec(sourcevar = c("1", "7"),
                origin = "BEC4", destination = "NAICS2002",
                dest.digit = 6, all = FALSE)

insongkim/concordance documentation built on Jan. 25, 2023, 4:55 p.m.