You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
While fct_lump() currently allows us to keep the N most frequent factors (lumping the rest into "Other"), I would love to have an option to this function (call it "inorder") which would instead preserve the firstN factors, lumping the rest into "Other".
To preserve the first two appearing levels of the factor, create function fct_lump_inorder(), all other levels are lumped into "Other":
f %>% fct_lump_inorder(2)
#> [1] hello goodbye Other Other
#> [5] Other hello
Levels: hello goodbye Other
Notice this is very useful if I have reordered a factor using fct_reorder() and now only want the first N of the list (akin to arrange() + head()). Example:
The text was updated successfully, but these errors were encountered:
dan-reznik
changed the title
function request: fct_lump_inorder
function request: allow fct_lump to lump factors based on order of appearance
Mar 16, 2019
dan-reznik
changed the title
function request: allow fct_lump to lump factors based on order of appearance
request: allow fct_lump to lump factors based on order of appearance
Mar 16, 2019
While
fct_lump()
currently allows us to keep theN
most frequent factors (lumping the rest into "Other"), I would love to have an option to this function (call it "inorder") which would instead preserve the firstN
factors, lumping the rest into "Other".To preserve the first two appearing levels of the factor, create function
fct_lump_inorder()
, all other levels are lumped into "Other":Notice this is very useful if I have reordered a factor using
fct_reorder()
and now only want the first N of the list (akin toarrange()
+head()
). Example:The text was updated successfully, but these errors were encountered: