Skip to contents

Groups data by time variables (ano, mes) and optional spatial variables (UF, municipio, regiao) and computes descriptive summaries of key numeric columns.

Usage

vigiar_agregar_tempo(
  dados,
  agregar_por = c("ano"),
  variavel = NULL,
  funcoes = list(media = function(x) mean(x, na.rm = TRUE), n = length)
)

Arguments

dados

A processed VIGIAR tibble (or any data frame with ano column).

agregar_por

Character vector of grouping variables. Default: c("ano"). Other options: "mes", "sigla_uf", "cod_municipio", "regiao".

variavel

Name of the numeric column to summarise. If NULL, auto-detects based on the data class.

funcoes

Named list of summary functions. Default: list(media = mean, n = length).

Value

A tibble with grouping columns and summary columns.

Examples

vigiar_agregar_tempo(pm25_rj_sample, agregar_por = "ano")
#> # A tibble: 3 × 3
#>     ano pm25_media_anual_media pm25_media_anual_n
#>   <int>                  <dbl>              <int>
#> 1  2020                  10.9                   5
#> 2  2021                   8.9                   5
#> 3  2022                   9.22                  5
vigiar_agregar_tempo(pm25_rj_sample, agregar_por = c("ano", "sigla_uf"))
#> # A tibble: 3 × 4
#>     ano sigla_uf pm25_media_anual_media pm25_media_anual_n
#>   <int> <chr>                     <dbl>              <int>
#> 1  2020 RJ                        10.9                   5
#> 2  2021 RJ                         8.9                   5
#> 3  2022 RJ                         9.22                  5