Skip to contents

get_brazil_municipality() returns a vector with codes of the Brazilian Institute of Geography and Statistics (IBGE) for Brazilian municipalities.

Usage

get_brazil_municipality_code(
  municipality,
  state = NULL,
  year = 2017,
  names = TRUE
)

Arguments

municipality

(optional) A character vector with the name of the municipalities. If NULL the function returns all municipalities (default: NULL).

state

(optional) A character vector with the name of the states (default: NULL).

year

(optional) An integerish number indicating the year of the data regarding the municipalities (default: 2017).

names

(optional) A logical flag indicating whether to return the names of the municipalities as names of the vector (default: TRUE).

Value

An integer vector with the IBGE codes of Brazilian municipalities.

Details

The data from this function is based on data from the Brazilian Institute of Geography and Statistics (IBGE) via the geobr R package.

The geobr package is produced by Brazil's Institute for Applied Economic Research (IPEA) and access the Brazilian Institute of Geography and Statistics (IBGE) data. You can see a list of all geobr datasets by running geobr::list_geobr().

Examples

get_brazil_municipality_code(municipality = "Belém")
#> Belém-PA Belém-PB Belém-AL 
#>  1501402  2501906  2700805 

get_brazil_municipality_code(municipality = "Belém", names = FALSE)
#> [1] 1501402 2501906 2700805

get_brazil_municipality_code(municipality = "Belém", state = "Pará")
#> Belém-PA 
#>  1501402 

get_brazil_municipality_code(municipality = c("Rio de Janeiro", "São Paulo"))
#> Rio de Janeiro-RJ      São Paulo-SP 
#>           3304557           3550308