reFactor: This function manipulates factor levels

View source: R/reFactor.r

reFactorR Documentation

This function manipulates factor levels

Description

This functions enables relabeling, reordering and merging of factor levels. It is also possible to add and exclude levels, and turn missing values into a separate level.

Usage

reFactor(x, L, na.level = NULL, exclude = NULL, new.last = FALSE, warn = TRUE)

Arguments

x

factor or character vector to be relabelled or reordered

L

a list specifying the relabeling/reordering

na.level

if not NULL all NA's will be a level with this label

exclude

a value to make into NA's

new.last

if TRUE then added levels will be placed last in the list of levels (default FALSE)

warn

do you want warnings when doing stupid things?

Note

This function will be refactor in the 'dataman' package. (It will be eventually be removed so as to not clutter the 'ucR' package too much, but I don't want to break to much code in current use!)

Author(s)

Henrik Renlund

See Also

factor, relevel

Examples

x <- LETTERS[1:5] # x <- factor(x)
L <- list(B=c("nyB", "C"),E=NULL, D="nyD")
reFactor(x,L)

renlund/ucR documentation built on March 25, 2023, 10:10 a.m.