relevel {stats} | R Documentation |
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.
relevel(x, ref, ...)
x |
an unordered factor. |
ref |
the reference level, typically a string. |
... |
additional arguments for future methods. |
This, as reorder()
, is a special case of simply calling
factor(x, levels = levels(x)[....])
.
A factor of the same length as x
.
factor
, contr.treatment
,
levels
, reorder
.
warpbreaks$tension <- relevel(warpbreaks$tension, ref = "M")
summary(lm(breaks ~ wool + tension, data = warpbreaks))