View source: R/summarise_var_by_strat.R
summarise_var_by_strat | R Documentation |
Sum a Stratified Variable by Stratification Level
summarise_var_by_strat(df, vars, strat = NULL, new_var, summary_var = FALSE)
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 |
Takes compartmental infectious disease output and adds summary statistics for each stratified population, optionally adding a final summary statistic for the whole population.
An updated data frame containing the summarised variable for each stratified level and for the whole population.
summarise_var_by_strat
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)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.