relevel

0th

Percentile

Reorder Levels of Factor

The levels of a factor are re-ordered so that the level specified by ref is first and the others are moved down. This is useful for contr.treatment contrasts which take the first level as the reference.

Keywords
models, utilities
Usage
relevel(x, ref, …)
Arguments
x

an unordered factor.

ref

the reference level, typically a string.

additional arguments for future methods.

Details

This, as reorder(), is a special case of simply calling factor(x, levels = levels(x)[....]).

Value

A factor of the same length as x.

See Also

factor, contr.treatment, levels, reorder.

Aliases
  • relevel
  • relevel.default
  • relevel.factor
  • relevel.ordered
Examples
library(stats) # NOT RUN { warpbreaks$tension <- relevel(warpbreaks$tension, ref = "M") summary(lm(breaks ~ wool + tension, data = warpbreaks)) # }
Documentation reproduced from package stats, version 3.5.1, License: Part of R 3.5.1

Community examples

Looks like there are no examples yet.