fct_clean | R Documentation |
A function to applied some forcats functions
fct_clean( x, na_level = "(Missing)", n = NULL, other_level = "Other", infreq = TRUE )
x |
A vector |
na_level |
If this argument is not null, then 'fct_explicit_na' is applied with this argument. |
n |
If this argument is not null, then 'fct_lump_n' is applied with 'n' and 'other_level'. |
other_level |
this argument is used if 'n' is not null. |
infreq |
Logical value to apply or not 'fct_infreq'. |
x1 <- c(rep(LETTERS[1:9], times = c(10, 40, 5, 27, 1, 1, 1, 1, 1)), rep(NA, 10)) x2 <- factor(x1) table(x1, useNA = "always") table(x2, useNA = "always") identical(fct_clean(x1), fct_clean(x2)) xf <- fct_clean(x1, n = 4) xf table(xf, useNA = "always")
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.