as_factor | R Documentation |
Converts a vector to a factor()
and ensures that levels are
in the order of the provided levels.
as_factor(x, levels, ordered = is.ordered(x))
x |
(atomic |
levels |
( |
ordered |
( |
(factor()
).
x = factor(c("a", "b"))
y = factor(c("a", "b"), levels = c("b", "a"))
# x with the level order of y
as_factor(x, levels(y))
# y with the level order of x
as_factor(y, levels(x))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.