
Generate tidyverse Code for Grouping and Aggregating Data
Source:R/codegen.R
sv_code_group_summarize.RdConstructs syntactically valid dplyr::group_by() and dplyr::summarise()
pipelines with identifier escaping, customizable summary metrics, and reproducible
grouping behavior via .groups = 'drop'.
Arguments
- df_name
Name of the data frame (optional; can be NULL for intermediate piped pipeline segments).
- group_cols
Character vector of grouping column name(s).
- summary_exprs
Named character vector or named list of aggregation expressions (e.g.,
c(total = "dplyr::n()", avg = "mean(val, na.rm = TRUE)")).- pipe
Logical; if TRUE, uses pipe syntax
df %>% dplyr::group_by(...) %>% dplyr::summarise(...). Defaults toFALSE.