Skip to content

add option to collapse text (and/or categorical?) values by frequency #37

@ccsarapas

Description

@ccsarapas

e.g., I used this helper to do it manually

fct_lump_min_lab <- function(f, min, w = NULL) {
  lump_name <- "_LUMPED_"
  lumped <- forcats::fct_lump_min(f = f, min = min, w = w, other_level = lump_name)
  n_lumped <- length(setdiff(levels(f), levels(lumped)))
  if (n_lumped) {
    names(lump_name) <- cli::pluralize(
      "[{n_lumped} other value{?s} with <{min} {cli::qty(n_lumped)} occurrences{? each}]"
    )
    lumped <- forcats::fct_recode(lumped, !!!lump_name)
  }
  lumped
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions