Skip to contents

Aggregate a data frame

Usage

aggregate_df(
  df,
  groups,
  sum_cols = NULL,
  mean_cols = NULL,
  weighted_mean_cols = NULL,
  w = NULL
)

Arguments

df

data.frame

groups

character vector of grouping variables

sum_cols

character vector of variables to summarise by sum

mean_cols

character vector of variables to summarise by mean

weighted_mean_cols

character vector of variables to summarise by weighted mean

w

column name for weights to be used for weighted mean summary

Value

An aggregated (un-grouped) data frame