## ----include = FALSE----------------------------------------------------------
knitr::opts_chunk$set(
  collapse = TRUE,
  comment = "#>"
)

## ----setup--------------------------------------------------------------------
library(epidesc)

data(dengueRio)
head(dengueRio)

## -----------------------------------------------------------------------------
dengue <- dengueRio
dengue$yearweek <- epiyearweek(dengue$date, start = "Sunday")
head(dengue)

## ----eval = FALSE-------------------------------------------------------------
# desc_list()

## ----echo=FALSE---------------------------------------------------------------
knitr::kable(desc_list())

## -----------------------------------------------------------------------------
descriptors <- list(
  Ap = list(fun = "Ap"),
  Cmax = list(fun = "Cmax", x = 5),
  Cnf = list(fun = "Cnf", n = 3, x = 5),
  Inc = list(fun = "Inc", p = 100000)
)

## -----------------------------------------------------------------------------
res <- desc_year(
  data = dengue,            # Input data frame
  cases = "cases",          # Name of the column of the cases
  time = "yearweek",        # Name of the column with the epiyearweek
  space = "muni_code",      # Name of the column with the spatial ID
  pop = "pop",              # Column with population, needed because of 'Inc'
  sweek = 41,               # Starting epiweek 41 for dengue in Brazil
  descriptors = descriptors # Descriptor list
)

## -----------------------------------------------------------------------------
head(res[res$epiyear == "2020/2021", ])

## -----------------------------------------------------------------------------
head(res[res$epiyear == "2016/2017", ])
head(res[res$epiyear == "2022/2023", ])

