calculate_cum: Cumulative Infection Numbers

calculate_cumR Documentation

Cumulative Infection Numbers

Description

Calculation of the cumulative values of infection numbers for infections panel data.

Usage

calculate_cum(
  object,
  col_name = NULL,
  overwrite = FALSE,
  verbose = FALSE
  )

Arguments

object

object of class infpan

col_name

character value specifying the column name of the computed cumulative values

overwrite

bool argument which indicates whether the column should be overwritten if already existing

verbose

bool argument which indicates whether progress messages are displayed

Details

Calculates the cumulative values of the infections panel data for all time points for each region. If col_name is NULL, the column is defined as "<Column name of cases>_cum". Set overwrite to TRUE, if an existing column should be overwritten. The method uses the function cumsum from the base package (see the corresponding documentation).

Value

infpan object including column with cumulative values in the infections panel data

Author(s)

Thomas Wieland

References

Wieland T (2020) Flatten the Curve! Modeling SARS-CoV-2/COVID-19 Growth in Germany at the County Level. REGION 7(2), 43–83. \Sexpr[results=rd]{tools:::Rd_expr_doi("https://doi.org/10.18335/region.v7i2.324")}

Wieland T (2020) A phenomenological approach to assessing the effectiveness of COVID-19 related nonpharmaceutical interventions in Germany. Safety Science 131, 104924. \Sexpr[results=rd]{tools:::Rd_expr_doi("https://doi.org/10.1016/j.ssci.2020.104924")}

See Also

infpan-class, load_infections_paneldata, calculate_Rt, calculate_incidence, calculate_rollmean

Examples

data(COVID19Cases_geoRegion)
# Get SWISS COVID19 cases at NUTS 3 level

COVID19Cases_geoRegion <- 
  COVID19Cases_geoRegion[!COVID19Cases_geoRegion$geoRegion %in% c("CH", "CHFL"),]
# Exclude CH = Switzerland total and CHFL = Switzerland and Liechtenstein total

COVID19Cases_geoRegion <- 
  COVID19Cases_geoRegion[COVID19Cases_geoRegion$datum <= "2020-05-31",]
# Extract first COVID-19 wave

infpan_CH <- load_infections_paneldata(
    data = COVID19Cases_geoRegion,
    col_cases = "entries",
    col_date = "datum",
    col_region = "geoRegion",
    other_cols = c("Population" = "pop"), 
    verbose = TRUE
  )
# Import as infections panel data set (class infpan)

infpan_CH <- calculate_cum(
  infpan_CH, 
  col_name = "cumulatives",
  verbose = TRUE
)
# Calculate rolling mean of cases as "cumulatives"

summary(infpan_CH)
# Summary of infpan object

swash documentation built on April 7, 2026, 1:06 a.m.