Skip to content

Integrate fct_other functionality into fct_collapse #100

@jmpsteen

Description

@jmpsteen

Thanks for this great package! I'm wondering though whether there would be any possibility of integrating features of fct_other into the fct_collapse function?

I currently need to recode a factor by collapsing a targeted set of levels (say c("A", "B", "C", "D", "E")) into new levels (say c("AB", "CDE")) and I want to recode all non-targeted levels (which usually is quite a long set of levels to manually specify, e.g. all other letters of the alphabet) into an "other" category. In other words: I'ld like fct_collapse to have an additional argument (similar to fct_other's other_level argument) that, when specified, automatically identifies all non-targeted levels (i.e. those not specified in any of the vectors, which in fct_other would be specified in the drop argument) and collapses these into a category with level name specified in this argument.

This feature would be quite helpful, because the only solution I can think of now is quite cumbersome. That is, I have to manually specify all new (collapsed) factor level names (entered in the fct_collapse call) in the keep argument of fct_other, while I assume these could easily be internally identified automatically in the fct_collapse function.

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