Converts a vector to a factor()
and ensures that levels are
in the order of the provided levels.
Usage
as_factor(x, levels, ordered = is.ordered(x))
Arguments
- x
(atomic
vector()
)
Vector to convert to factor.- levels
(
character()
)
Levels of the new factor.- ordered
(
logical(1)
)
IfTRUE
, create an ordered factor.
Value
(factor()
).