sum_groups_epi_df: Aggregate an 'epi_df' object

View source: R/methods-epi_df.R

sum_groups_epi_dfR Documentation

Aggregate an epi_df object

Description

Aggregates an epi_df object by the specified group columns, summing the value column, and returning an epi_df. If aggregating over geo_value, the resulting epi_df will have geo_value set to "total".

Usage

sum_groups_epi_df(.x, sum_cols, group_cols = "time_value")

Arguments

.x

an epi_df

sum_cols

<tidy-select> An unquoted column name (e.g., cases), multiple column names (e.g., c(cases, deaths)), other tidy-select expression, or a vector of characters (e.g. c("cases", "deaths")). Variable names can be used as if they were positions in the data frame, so expressions like x:y can be used to select a range of variables.

group_cols

character vector of column names to group by. "time_value" is included by default.

Value

an epi_df object

Examples

# This data has other_keys age_group and edu_qual:
grad_employ_subset

# Aggregate num_graduates within each geo_value (and time_value):
grad_employ_subset %>%
  sum_groups_epi_df(num_graduates, group_cols = "geo_value")


cmu-delphi/epitools documentation built on April 17, 2025, 3:33 a.m.