get_product: Looking Up Product Codes By Keywords

get_productR Documentation

Looking Up Product Codes By Keywords

Description

Returns product codes for which descriptions match user-specified keywords.

Usage

get_product(pattern, origin, digits = 4, type = "regex", ignore.case = TRUE)

Arguments

pattern

String pattern to look for. The function utilizes the function stringr::str_detect for pattern detection.

origin

A string indicating one of the following industry/product classifications: "HS0" (1988/92), "HS1" (1996), "HS2" (2002), "HS3" (2007), "HS4" (2012), "HS5" (2017), "HS6" (2022), "HS" (combined), "SITC1" (1950), "SITC2" (1974), "SITC3" (1985), "SITC4" (2006), "NAICS2002", "NAICS2007", "NAICS2012", "NAICS2017", "ISIC2" (1968), "ISIC3" (1989), "ISIC4" (2008), "BEC4" (2016).

digits

An integer indicating the preferred number of digits for output codes. The default is 4 digits. Allows 1 to 5-digit codes for the SITC classification; 2, 4, 6-digit codes for NAICS and HS classifications; 1 to 4-digit codes for the ISIC classification; 1 to 3-digit codes for the BEC classification.

type

A string indicating the type of pattern interpretation. Three options are available: regex, fixed, and coll. The default interpretation is a regular expression. See ?str_detect for further details.

ignore.case

If TRUE (by default), pattern dection will ignore case differences.

Value

A character vector of product codes that match user specified description patterns.

Source

Product descriptions consolidated from

  • The U.S. Census Bureau <https://www.census.gov/>

  • The U.S. Bureau of Labor Statistics <https://www.bls.gov/>

  • UN Comtrade <https://comtrade.un.org/>

  • UN Trade Statistics <https://unstats.un.org/unsd/trade/default.asp>

Examples

# find manufacture-related NAICS codes
manu.vec <- get_product(pattern = "manu", origin = "NAICS2017", digits = 4,
                        type = "regex", ignore.case = TRUE)
manu.vec

# check product description
get_desc(manu.vec, origin = "NAICS2017")

# 6-digit outputs
get_product(pattern = "manu", origin = "NAICS2017", digits = 6,
            type = "regex", ignore.case = TRUE)

# choose different interpretation types
get_product(pattern = "manu", origin = "NAICS2017", digits = 4,
            type = "fixed", ignore.case = TRUE)
get_product(pattern = "manu", origin = "NAICS2017", digits = 4,
            type = "coll", ignore.case = TRUE)

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