now I'm learning forcats fct_lump_*
I can't specify the number of counts and make it OTHER.
I read
https://forcats.tidyverse.org/reference/fct_lump.html
and It said
Use fct_lump_min() to lump together all levels with fewer than `n` values
I thought,
if I use add_count + fct_lump_min, I can clasifiy "under freq = 2" .
set.seed(2021)
df <- tibble(tt = LETTERS[c(sample(26)[1:20],sample(26)[1:10],sample(26)[1:10],sample(26)[1:10])])
table(df$tt)
df %>%
add_count(tt) %>%
slice(1:26) %>%
mutate(fff = fct_lump_min(tt,min = 2, other_level = "under 2")) %>%
arrange(desc(n))
return is
1 U 4 U
2 I 4 I
3 K 4 Other
4 U 4 U
5 I 4 I
6 S 3 S
7 S 3 S
8 V 3 Other
why V and K is include Other ?
I want to make 2 and 1 OTHER.
thank you.