concord_hs {concordance} | R Documentation |
Concord Within HS Codes
Description
Concords codes within the Harmonized System classification (HS0, HS1, HS2, HS3, HS4, HS5).
Usage
concord_hs(sourcevar, origin, destination, dest.digit = 4, all = FALSE)
Arguments
sourcevar |
An input character vector of HS codes. The function accepts 2, 4, 6-digit HS codes. |
origin |
A string setting the input industry classification: "HS0" (1988/92), "HS1" (1996), "HS2" (2002), "HS3" (2007), "HS4" (2012), and "HS5" (2017). |
destination |
A string setting the output industry classification: "HS0" (1988/92), "HS1" (1996), "HS2" (2002), "HS3" (2007), "HS4" (2012), and "HS5" (2017). |
dest.digit |
An integer indicating the preferred number of digits for output codes. Allows 2, 4, or 6-digit HS codes. The default is 4 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.
Note
Always include leading zeros in codes (e.g. use HS code 010110 instead of 10110)—results may be buggy otherwise.
Source
Concordance tables provided by:
United Nations Trade Statistics <https://unstats.un.org/unsd/trade/classifications/correspondence-tables.asp>
Examples
# HS5 to HS4
concord(sourcevar = c("1206", "8546"),
origin = "HS5", destination = "HS4",
dest.digit = 4, all = TRUE)
# HS0 to HS5
concord(sourcevar = c("010111", "382390"),
origin = "HS0", destination = "HS5",
dest.digit = 6, all = TRUE)