Skip to content

fct_lump() shouldn't relabel if no lumping occurs #130

Closed
@ahhaque

Description

@ahhaque

If in a vector, only one value appears less than the 'prop' times, fct_lump creates a new level called 'other'. Ideally, it should keep the original level name as only one level was affected.

Example:
nRows <- 500
vec <- as.factor(c(rep("X",0.32nRows),rep("Y",0.08nRows), rep("Z",0.4nRows), rep('W', 0.2nRows)))
rebinned_vec <- fct_lump(vec, prop = 0.1)

prop.table(table(rebinned_vec)) gives the following output:
W X Z Other
0.20 0.32 0.40 0.08

In the above code, only the level 'Y' should be affected as it has less than 10% share. But since this is the only level affected, isn't it expected that fct_lump will leave the level 'Y' as it is rather than creating the 'other' level?

Metadata

Metadata

Assignees

No one assigned

    Labels

    featurea feature request or enhancement

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions