Learn R Programming

censuspyrID (version 1.0.2)

year_range: Get Census Year Coverage for a Province

Description

This function determines the range of census years available for a given province. Coverage depends on whether harmonized or non-harmonized codes are used, and in the case of non-harmonized data, whether the province has experienced administrative expansion (pemekaran).

Usage

year_range(reg_code = NULL, harmonized = TRUE, before_expand = TRUE)

Value

An integer vector of census years, with labels as names.

Arguments

reg_code

Character or numeric. Province code. Required if harmonized = FALSE.

harmonized

Logical. If TRUE (default), returns harmonized coverage (1971–2020). If FALSE, uses non-harmonized coverage.

before_expand

Logical. Only relevant if harmonized = FALSE and the province has expanded. If TRUE (default), returns coverage before expansion; if FALSE, returns coverage after expansion.

Details

  • For harmonized data (harmonized = TRUE), the full coverage of 1971–2020 is returned.

  • For non-harmonized data (harmonized = FALSE), coverage is determined based on the internal dataset prov_coverage.

  • If the province has expanded, coverage depends on before_expand.

  • Census year labels are retrieved from ref_label$census_label.

See Also

is_expanded(), get_code_label()

Examples

Run this code
if (FALSE) {
# Harmonized coverage (1971–2020)
year_range(harmonized = TRUE)

# non-harmonized coverage for a province (before expansion)
get_code_label(5) #returns list of non-harmonized province code
year_range(reg_code = 1400, harmonized = FALSE, before_expand = TRUE)

# non-harmonized coverage for a province (after expansion)
year_range(reg_code = 1400, harmonized = FALSE, before_expand = FALSE)
}

Run the code above in your browser using DataLab