Skip to contents

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

Usage

brazil_state_code(x = NULL)

Arguments

x

(optional) An atomic vector containing the names of Brazilian states or federal units. Municipality codes are also supported. If NULL, returns a vector with all state codes (default: NULL).

Value

An integer vector with the IBGE codes of Brazilian states.

Details

The data from this function is based on data from the Brazilian Institute of Geography and Statistics (IBGE, n.d.).

References

Instituto Brasileiro de Geografia e Estatística. (n.d.). Território [Territory] [Dataset]. SIDRA. https://sidra.ibge.gov.br/territorio

Examples

brazil_state_code()
#>                Acre             Alagoas               Amapá 
#>                  12                  27                  16 
#>            Amazonas               Bahia               Ceará 
#>                  13                  29                  23 
#>    Distrito Federal      Espírito Santo               Goiás 
#>                  53                  32                  52 
#>            Maranhão         Mato Grosso  Mato Grosso do Sul 
#>                  21                  51                  50 
#>        Minas Gerais                Pará             Paraíba 
#>                  31                  15                  25 
#>              Paraná          Pernambuco               Piauí 
#>                  41                  26                  22 
#>      Rio de Janeiro Rio Grande do Norte   Rio Grande do Sul 
#>                  33                  24                  43 
#>            Rondônia             Roraima      Santa Catarina 
#>                  11                  14                  42 
#>           São Paulo             Sergipe           Tocantins 
#>                  35                  28                  17 

brazil_state_code("ac")
#> [1] 12
#> [1] 12 # Expected

brazil_state_code("acre")
#> [1] 12
#> [1] 12 # Expected

brazil_state_code(3550308) # São Paulo
#> [1] 35
#> [1] 35 # Expected

brazil_state_code(35503081) # >7 digits
#> [1] NA
#> [1] NA # Expected

brazil_state_code(3912345) # Non-existent state code
#> [1] NA
#> [1] NA # Expected