Categorizes six-digit administrative division codes of the People's Republic of China (as per GB/T 2260-2007) into several structured components, including province, city, area type (urban/rural), registry code, and regional classification.
classify_areacode2(x, attr = "registry")
A vector of six-digit Chinese administrative area codes, either as numeric or character strings.
A character vector of attributes to return. Options include:
"registry"
: Cancer registry codes.
"province"
: Province-level codes.
"city"
: City-level codes.
"area_type"
: Urban/rural classification.
"region"
: Regional classification based on province.
Any other string will be treated as a custom dictionary name written
using write_registry()
.
A list with the following named elements:
areacode
: Validated area codes. Invalid entries are replaced with NA
.
registry
: Registry codes corresponding to each area, using a built-in
or cached dictionary.
province
: Province-level codes formed by taking the first two digits and
appending "0000"
.
city
: City-level codes formed by taking the first four digits and
appending "00"
.
area_type
: Urban-rural classification codes: "910000"
for urban,
"920000"
for rural. This can be updated using write_registry()
function which stored the dictionary in (area_type_dict.rds
)
region
: Region classification codes derived from province codes,
ending in "0000"
.
This function standardizes and validates area codes, identifies their
administrative levels, and attaches metadata used in cancer registration
systems. It also supports external dictionaries (from the canregtools
configuration folder) to provide more accurate classification of area types
and registry mapping. Classify Codes for the administrative divisions of
the People's Republic of China(GB/T 2260-2007) into different categories,
including 'province', city', 'area_type', and 'registry' attributes.
classify_areacode(c("110000", "320500", "440300"))
#> $areacode
#> [1] "110000" "320500" "440300"
#>
#> $registry
#> [1] "110000" "320500" "440300"
#>
#> $province
#> [1] "110000" "320000" "440000"
#>
#> $city
#> [1] "110000" "320500" "440300"
#>
#> $area_type
#> [1] "910000" "910000" "910000"
#>
#> $region
#> [1] "720000" "740000" "760000"
#>