NAICS - query NAICS codes and also see all children (subcategories) of any of those
Source:R/NAICS_FUNCTIONS.R
naics2children.Rd
Used by naics_find()
Usage
naics2children(codes, allcodes = EJAM::NAICS, quiet = FALSE)
Details
Starts with shortest (highest level) codes. Since tied for nchar, these branches have zero overlap, so do each.
For each of those, get its
children = all
rows whereparentcode == substr(allcodes, 1, nchar(parentcode))
Put together list of all codes we want to include so far.
For the next longest set of codes in original list of codes, do same thing.
continue until done for 5-digit ones to get 6-digit children.
Take the
unique(allthat)
table(nchar(as.character(NAICS)))
2 3 4 5 6
17 99 311 709 1057
See also
naics_find()
NAICS