fct_collapse_only | R Documentation |
This collapses levels and only keeps those new group levels, in the order provided. The returned factor has levels in the order given, with the possible missing level last (this will only be included if there are missing values).
fct_collapse_only(.f, ..., .na_level = "<Missing>")
.f |
( |
... |
(named |
.na_level |
( |
A modified factor
with collapsed levels. Values and levels which are not included
in the given character
vector input will be set to the missing level .na_level
.
Any existing NA
s in the input vector will not be replaced by the missing level. If needed,
explicit_na()
can be called separately on the result.
forcats::fct_collapse()
, forcats::fct_relevel()
which are used internally.
fct_collapse_only(factor(c("a", "b", "c", "d")), TRT = "b", CTRL = c("c", "d"))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.