| anycensus | R Documentation |
The function queries a long format census data frame
(censuskor) for specific administrative codes (if provided)
anycensus(
year = 2020,
codes = NULL,
type = c("population", "housing", "tax", "mortality", "economy", "medicine",
"migration", "environment", "welfare", "social security", "landuse"),
level = c("adm2", "adm1"),
aggregator = sum,
geometry = FALSE,
...
)
year |
integer(1). One of 2010, 2015, or 2020. |
codes |
integer vector of admin codes (e.g. |
type |
character(1). "population", "housing", "tax", "economy", "medicine", "migration", "environment", "mortality", "social security", or "landuse". Defaults to "population". |
level |
character(1). "adm1" for province-level or "adm2" for municipal-level. Defaults to "adm2". |
aggregator |
function to aggregate values when |
geometry |
logical(1). If |
... |
additional arguments passed to the |
A data.frame object containing census data for the specified codes and year.
Using characters in codes has a side effect of returning
all rows in the dataset that match year and type.
The 'wide' table is returned with separate columns for each
class1 and class2 and unit (abbreviated whereof) combination.
# Query mortality data for adm2_code 21 (Busan)
anycensus(codes = 21, type = "mortality")
# Query population data for adm1 "Seoul" or "Daejeon"
anycensus(codes = c("Seoul", "Daejeon"), type = "housing", year = 2015)
# Aggregate to adm1 level tax (province-level) using sum
anycensus(
codes = c(11, 23, 31),
type = "tax",
year = 2020,
level = "adm1",
aggregator = sum,
na.rm = TRUE
)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.