mergecat: Merging and renaming categories

mergeCatsR Documentation

Merging and renaming categories

Description

Functions for merging and renaming categories in character or factor columns.

Usage

mergeCats(x, ..., asFactor = F, levels = NULL)

renameCats(x, ..., asFactor = F, levels = NULL)

Arguments

x

A column or vector whose categories are to be merged or renamed.

...

The name of each argument is a new category, and the value of each argument is a vector of names of old categories (as character values, even if the original column/vector contains factors).

asFactor

Do you want the result to be a factor?

levels

If asFactor = T, you an use this to set the levels of the factor.

Value

A column or vector with the desired changes.

Examples

sbc007 = changeField(sbc007, entity = "token", layer = "",
                              fieldName = "kind",
                              expression = mergeCats(kind, Vocalism = c("Laugh", "Vocalism")))
          sbc007 = changeField(sbc007, entity = "token", layer = "",
                               fieldName = "kind",
                               expression = renameCats(kind, Voc = "Vocalism"))

johnwdubois/rezonateR documentation built on Nov. 19, 2024, 11:17 p.m.