adicionar_territorio: Add territorial attributes to a data frame

View source: R/geography.R

adicionar_territorioR Documentation

Add territorial attributes to a data frame

Description

Validates a territorial code column and appends the corresponding current IBGE names and hierarchy. Six-digit DATASUS municipality codes are converted to seven-digit IBGE codes. The function does not redistribute historical observations across boundary changes.

Usage

adicionar_territorio(
  dados,
  codigo,
  nivel = c("municipio", "uf", "regiao"),
  desconhecido = c("erro", "na"),
  sobrescrever = FALSE
)

Arguments

dados

A data frame.

codigo

Name of the territorial code column.

nivel

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

desconhecido

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

sobrescrever

Whether existing columns with catalog names may be replaced.

Value

'dados' with territorial columns appended.

Examples

dados <- data.frame(codmun = c("500270", "500370"), casos = c(10, 5))
adicionar_territorio(dados, "codmun")

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