Learn R Programming

BrazilDataAPI (version 0.1.0)

get_brazil_municipalities: Get Municipalities of a Brazilian State from IBGE

Description

This function retrieves a list of municipalities from the Brazilian IBGE API using the state abbreviation (UF). It includes the name of each municipality and its official IBGE code.

Usage

get_brazil_municipalities(uf)

Value

A data frame (tibble) with the following columns:

  • nome: Name of the municipality.

  • codigo_ibge: Official IBGE code for the municipality (as character).

Arguments

uf

A two-letter string representing the Brazilian state abbreviation (e.g., "SP", "RJ", "BA").

Details

The function sends a GET request to the BrasilAPI IBGE endpoint. If the UF (state abbreviation) is invalid or not recognized, the function returns NULL with an appropriate message.

See Also

Examples

Run this code
if (FALSE) {
municipalities_sp <- get_brazil_municipalities("SP")
head(municipalities_sp)
}

Run the code above in your browser using DataLab