Format municipio codes with leading zeroes

str_mxmunicipio(code, municipio_code)

Arguments

code

The sate or combined state and municipio code if the municipio_code variable is missing

municipio_code

The municipio code

Value

The state and municipio code in the format required by the plotting functions

Examples

# Format the concatenated string of state code + municipio code
str_mxmunicipio(c("1006", "2003"))
#> [1] "01006" "02003"
# Format the state and municipio code separately
str_mxmunicipio(c(10, 6), c(20, 3))
#> [1] "10020" "06003"

if (FALSE) {
# warning about invalid code
str_mxmunicipio(33, 999)
}