refactor: This function manipulates factor levels

Description Usage Arguments Author(s) See Also Examples

View source: R/refactor.r

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

1
2
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?

Author(s)

Henrik Renlund

See Also

factor, relevel

Examples

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

renlund/dataman documentation built on May 27, 2019, 5:51 a.m.