| completar_territorios | R Documentation |
Adds absent territory-period rows while protecting existing observations. By default the territorial universe is the set observed in 'dados'. Supply 'uf' to complete all current territories in one or more states, or 'territorios' for an explicit universe. If 'periodos' is omitted, the distinct periods observed in the data are used.
completar_territorios(
dados,
codigo,
periodo = NULL,
grupo = NULL,
nivel = c("municipio", "uf", "regiao"),
territorios = NULL,
uf = NULL,
periodos = NULL,
preencher = list(),
adicionar = TRUE
)
dados |
A data frame. |
codigo |
Name of the territorial code column. |
periodo |
Optional name of the period column. |
grupo |
Optional names of grouping columns whose observed combinations must be completed separately. |
nivel |
Territorial level: '"municipio"', '"uf"' or '"regiao"'. |
territorios |
Optional vector defining the territorial universe. |
uf |
Optional state selector used to define the current territorial universe. For municipality data it includes every current municipality in the selected states. |
periodos |
Optional vector defining the period universe. |
preencher |
Named list of scalar values used only for rows created by the function, for example 'list(casos = 0)'. |
adicionar |
Whether to append current territorial attributes with [adicionar_territorio()]. |
A data frame ordered by groups, territory and period.
dados <- data.frame(
codmun = c("500270", "500270", "500370"),
ano = c(2023, 2025, 2023),
casos = c(10, 12, 5)
)
completar_territorios(
dados, "codmun", "ano",
periodos = 2023:2025,
preencher = list(casos = 0)
)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.