Merging and renaming categories
mergecat.Rd
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.
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"))