setlevels | R Documentation |
A function to set levels of a factor object.
setlevels(x, old=levels(x), new, skip_absent=FALSE)
x |
A factor object. |
old |
A character vector containing the factor levels to be changed. Default is levels of |
new |
The new character vector containing the factor levels to be added. |
skip_absent |
Skip items in |
Returns an invisible and modified factor object.
Morgan Jacob
x = factor(c("A", "A", "B", "B", "B", "C")) # factor vector with levels A B C
setlevels(x, new = c("X", "Y", "Z")) # set factor levels to: X Y Z
setlevels(x, old = "X", new = "A") # set factor levels X to A
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.