Description Usage Arguments Details Value Examples
This function is a variant of fct_lump_lowfreq from forcats, but instead of
lumping together levels such that the "Other" category is smaller than all
others, it lumps together levels such that the "Other" category is smaller
than the kth-most numerous, for some k.
1 | fct_lump_lowfreq2(f, other_level = "Other", k = 1, prop = 1)
|
f |
A factor |
other_level |
The name to use for the "Other" level. Defaults to
|
k, prop |
The function compares to the |
As you might imagine, this function borrows heavily from the source code from
forcats for fct_lump_lowfreq, and is used with the appropriate permission.
A reordered factor
1 2 3 4 5 6 7 | # Requires magrittr for pipes
x <- factor(rep(LETTERS[1:9], times = c(40, 10, 5, 27, 1, 1, 1, 1, 1)))
x %>% table()
x %>% fct_lump_lowfreq2() %>% table()
x %>% fct_lump_lowfreq2(k = 3, other = "Others") %>% table()
x %>% fct_lump_lowfreq2(prop = 1.5) %>% table()
# (Examples modified from forcats)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.