Skip to content

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

@robinsones

Description

@robinsones

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    featurea feature request or enhancementtidy-dev-day 🤓Tidyverse Developer Day rstd.io/tidy-dev-day

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions