Combine values from different groups if specific groups only have a low contribution to the overall value.

combine_groups(
  data,
  group_col,
  groups = names(data)[!is.element(names(data), c("atoutput", "time", group_col))],
  combine_thresh = 15
)

Arguments

data

Dataframe whose groups shall be combined.

group_col

Character string giving the name of the group column in `data`.

groups

Vector of character strings giving the grouping variables.

combine_thresh

Integer indicating the number of groups to display. Default is 15.

Value

dataframe with groups combined to "Rest" if contribution is low.

See also

Other combine functions: combine_runs()

Examples

df <- combine_groups(ref_dm, group_col = "prey")
#> Warning: `arrange_()` was deprecated in dplyr 0.7.0. #> Please use `arrange()` instead. #> See vignette('programming') for more help
#> Joining, by = c("pred", "agecl", "prey")
df <- combine_groups(ref_dm, group_col = "prey", combine_thresh = 2)
#> Joining, by = c("pred", "agecl", "prey")
#> Joining, by = c("pred", "agecl", "prey")