| detect_adm2_type | R Documentation |
adm2_code often refers to the codes of autonomous _Gu_s or non-autonomous _Gu_s. The head table of the data frame may contain either or both of the two types of codes. This function detects the type of the codes in the adm2_code field and returns the exact codes accordingly.
detect_adm2_type(df, year = NULL, mode = "non", adm2_code = "adm2_code")
df |
A head data frame containing the full dataset.
i.e., |
year |
The year for which to filter the data. If not specified, the function will use the data.frame as is. |
mode |
A character vector of "atn" (autonomous) and "non" (non-autonomous). |
adm2_code |
A character vector of adm2_code field Default is "adm2_code". |
filtered data frame with exact codes
# Load 2020 census population
pop20 <- anycensus(year = 2020, type = "population")
pop20_nonauto <- detect_adm2_type(pop20, mode = "non")
pop20_auto <- detect_adm2_type(pop20, mode = "atn")
unique(pop20_nonauto$adm2_code)
unique(pop20_auto$adm2_code)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.