Select rows in the top n groups according to some summarization operation
top_n_groups(df, group_var, val_var, val_fun = sum)
df | data frame |
---|---|
group_var | grouping variable |
val_var | value assessment variable to be summarized by group |
val_fun | value assessment function to apply to |
data frame only with observations from top groups