small2other {multiUS}R Documentation

Recoding the smallest categories to "other" value in case of too many or too small categories.

Description

The smallest categories are recoded to "other" or user specified string. The variables is converted to factor if not already.

Usage

small2other(
  x,
  maxLevels = 12,
  minFreq = 0,
  otherValue = "other",
  convertNA = TRUE,
  orderLevels = FALSE,
  otherLast = FALSE
)

Arguments

x

The variable to be recoded.

maxLevels

The maximum number of levels after recoding

minFreq

The minimal frequency after recoding.

otherValue

The name give to the new category

convertNA

Should the NA values be converted to ordinary values. If TRUE, they are converted to string "NA". If FALSE, there are left as missing and ignored in the recording.

orderLevels

How should the categories be ordered. Possible values are:

  • FALSE - do not change the ordering (default)

  • alpha - alphabetically; and

  • freq - based on frequencies (highest frequencies first).

otherLast

Only used if category with otherValue was created. If TRUE, the otherValue is placed as last category regardless of the orderLevels argument. Defaults to FALSE.


[Package multiUS version 1.2.3 Index]