compress_field: Compress Field into Fewer Categories

compress_fieldR Documentation

Compress Field into Fewer Categories

Description

Merge the less common terms into a single group

Usage

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("bibliographica")

Examples

  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")

rOpenGov/bibliographica documentation built on April 10, 2022, 8:51 p.m.