Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Inconsistent behavior for fct_lump() when n or prop is a character #169

Closed
robinsones opened this issue Jan 19, 2019 · 2 comments · Fixed by #239
Closed

Inconsistent behavior for fct_lump() when n or prop is a character #169

robinsones opened this issue Jan 19, 2019 · 2 comments · Fixed by #239
Labels
feature a feature request or enhancement tidy-dev-day 🤓 Tidyverse Developer Day rstd.io/tidy-dev-day

Comments

@robinsones
Copy link
Contributor

While fct_lump() keeps all the levels if you set n equal to a character, it sets them all to other when you set prop equal to a character.

Reprex:

library(forcats)
x <- factor(letters[rpois(10, 5)])
# this keeps all the levels
fct_lump(x, n = "a")
#>  [1] c c b f e c b c n h
#> Levels: b c e f h n

# this makes everything "Other"
fct_lump(x, prop = "a")
#>  [1] Other Other Other Other Other Other Other Other Other Other
#> Levels: Other

Created on 2019-01-19 by the reprex package (v0.2.1)

My personal opinion is that these should both result in an error instead, but I think they should at least be consistent.

@hadley
Copy link
Member

hadley commented Jan 19, 2019

Agreed, definitely should be an errror.

@robinsones

This comment has been minimized.

@hadley hadley added the feature a feature request or enhancement label Jan 24, 2019
@hadley hadley added the tidy-dev-day 🤓 Tidyverse Developer Day rstd.io/tidy-dev-day label Jan 21, 2020
hadley pushed a commit that referenced this issue Jan 31, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature a feature request or enhancement tidy-dev-day 🤓 Tidyverse Developer Day rstd.io/tidy-dev-day
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants