lump: Generic lumping

Description Usage Arguments Value

View source: R/lump.R

Description

Takes levels (labels, factor levels) and corresponding counts and "lumps" according to specified criteria (either n or prop), i.e. preserves some rows and summarises the rest in a single "Other" row

Usage

1
2
3
4
5
6
7
8
lump(
  levels,
  count,
  n,
  prop,
  other_level = "Other",
  ties.method = c("min", "average", "first", "last", "random", "max")
)

Arguments

levels

Vector of levels

count

Vector of corresponding counts

n

If specified, n rows shall be preserved.

prop

If specified, rows shall be preserved if their count >= prop

other_level

Name of the "other" level to be created from lumped rows

ties.method

Method to apply in case of ties

Value

A dictionary (named vector) of levels -> new levels


tidytidbits documentation built on March 8, 2021, 5:07 p.m.