lump {tidytidbits}R Documentation

Generic lumping

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

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


[Package tidytidbits version 0.3.2 Index]