normalizar_codigo_ibge: Normalize IBGE territorial codes

View source: R/geography.R

normalizar_codigo_ibgeR Documentation

Normalize IBGE territorial codes

Description

Validates current territorial identifiers against the bundled IBGE reference. Municipality inputs may use the full seven-digit IBGE code or the six-digit form commonly returned by DATASUS. State and region inputs may also use abbreviations or full names.

Usage

normalizar_codigo_ibge(
  codigo,
  nivel = c("municipio", "uf", "regiao"),
  formato = NULL,
  desconhecido = c("erro", "na", "manter")
)

Arguments

codigo

Vector of territorial identifiers.

nivel

Territorial level: '"municipio"', '"uf"' or '"regiao"'.

formato

Output format. Municipalities support '"ibge"' (seven digits) and '"datasus"' (six digits). States and regions additionally support '"sigla"' and '"nome"'.

desconhecido

How to handle unknown values: '"erro"', '"na"' or '"manter"'.

Value

A character vector with the same length as 'codigo'.

Examples

normalizar_codigo_ibge(c("500270", "5003702"))
normalizar_codigo_ibge(c("MS", "Mato Grosso do Sul"), "uf", "ibge")

datasus documentation built on Oct. 7, 2026, 1:07 a.m.