fct_cut
converts numeric variables to a factor using the breaks
provided. It is built on cut
, but does some additional
coercion before passing to cut
and labels the output in more
lay-friendly manner. Note that intervals in fct_cut
are closed on the
left (they include the lower value and exclude the higher - e.g.
1 <= .x < 2
); this is the opposite of cut
's default behavior.
fct_cut(.x, breaks = quantile(.x), open = FALSE, ordered = TRUE)
.x | A numeric vector, or a object that can be coerced to one. If
|
---|---|
breaks | A numeric vector of break points for the categories of
|
open | Should the ends of |
ordered | Should the resulting factor be ordered? Since numeric data is
inherently ordered, the default is |
A factor