summarise_var_by_strat {idmodelr}R Documentation

Sum a Stratified Variable by Stratification Level

Description

Sum a Stratified Variable by Stratification Level

Usage

summarise_var_by_strat(df, vars, strat = NULL, new_var, summary_var = FALSE)

Arguments

df

A dataframe of model output.

vars

A character vector containing the unstratified variables to summarise

strat

The number of stratifications present in the data set

new_var

The name of the summarised variable

summary_var

A logical (defaults to FALSE), specifying whether to add an additional summary variable across all stratified levels when aggregating incidence.

Details

Takes compartmental infectious disease output and adds summary statistics for each stratified population, optionally adding a final summary statistic for the whole population.

Value

An updated data frame containing the summarised variable for each stratified level and for the whole population.

See Also

summarise_var_by_strat

Examples

df <- data.frame(A = 1, B = 2)
summarise_var_by_strat(df, vars = c("A", "B"), new_var = "C")

df <- data.frame(A1 = 1, B1 = 1, A2 = 1, B2 = 1, A3 = 1, B3 = 1)
summarise_var_by_strat(df, vars = c("A", "B"), strat = 3, new_var = "C")
summarise_var_by_strat(df, vars = c("A", "B"), strat = 3, new_var = "C", summary_var = TRUE)

[Package idmodelr version 0.4.0 Index]