compress_field: Compress Field into Fewer Categories

Description Usage Arguments Details Value Author(s) References Examples

Description

Merge the less common terms into a single group

Usage

1
compress_field(x, topn = NULL, min.freq = NULL, rest = "Other")

Arguments

x

Vector or factor.

topn

Number of top entries to include; or a character vector

min.freq

Minimum frequency for the included groups.

rest

Name to be used for the remaining entries

Details

With the min.freq argument, groups that have less items that this will be merged.

Value

Compressed version of the input.

Author(s)

Leo Lahti leo.lahti@iki.fi

References

See citation("comhis")

Examples

1
2
3
4
  p <- compress_field(c("A", "A", "A", "B","B","C", "D"),
         topn = 2, rest = "Other")
  p <- compress_field(c("A", "A", "A", "B","B","C", "D"),
         topn = c("A", "B"), rest = "Other")

COMHIS/comhis documentation built on Aug. 15, 2021, 11:07 a.m.