Skip to contents

get_brazil_municipality() returns a tibble with data about Brazilian municipalities.

Usage

get_brazil_municipality(
  municipality = NULL,
  state = NULL,
  year = 2017,
  force = FALSE
)

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).

force

(optional) A logical flag indicating whether to force the download of the data again (default: FALSE).

Value

A tibble with the following columns:

  • region_code: The region code.

  • region: The region name.

  • state_code: The state code.

  • state: The state name.

  • federal_unit: The state abbreviation.

  • municipality_code: The municipality code.

  • municipality: The municipality name.

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() |> dplyr::glimpse()
#> Rows: 5,570
#> Columns: 7
#> $ region_code       <int> 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1…
#> $ region            <chr> "North", "North", "North", "North", "North", "North"…
#> $ state_code        <int> 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 
#> $ state             <chr> "Rondônia", "Rondônia", "Rondônia", "Rondônia", "Ron…
#> $ federal_unit      <chr> "RO", "RO", "RO", "RO", "RO", "RO", "RO", "RO", "RO"…
#> $ municipality_code <int> 1100015, 1100023, 1100031, 1100049, 1100056, 1100064…
#> $ municipality      <chr> "Alta Floresta D'Oeste", "Ariquemes", "Cabixi", "Cac…

get_brazil_municipality(municipality = "Belém")
#> # A tibble: 3 × 7
#>   region_code region    state_code state   federal_unit municipality_code
#>         <int> <chr>          <int> <chr>   <chr>                    <int>
#> 1           1 North             15 Pará    PA                     1501402
#> 2           2 Northeast         25 Paraíba PB                     2501906
#> 3           2 Northeast         27 Alagoas AL                     2700805
#> # ℹ 1 more variable: municipality <chr>

get_brazil_municipality(municipality = "Belém", state = "Pará")
#> # A tibble: 1 × 7
#>   region_code region state_code state federal_unit municipality_code
#>         <int> <chr>       <int> <chr> <chr>                    <int>
#> 1           1 North          15 Pará  PA                     1501402
#> # ℹ 1 more variable: municipality <chr>

get_brazil_municipality(municipality = c("Belém", "São Paulo"))
#> # A tibble: 4 × 7
#>   region_code region    state_code state     federal_unit municipality_code
#>         <int> <chr>          <int> <chr>     <chr>                    <int>
#> 1           1 North             15 Pará      PA                     1501402
#> 2           2 Northeast         25 Paraíba   PB                     2501906
#> 3           2 Northeast         27 Alagoas   AL                     2700805
#> 4           3 Southeast         35 São Paulo SP                     3550308
#> # ℹ 1 more variable: municipality <chr>