fct_drop: Drop unused levels preserving label data

View source: R/fct_drop.R

fct_dropR Documentation

Drop unused levels preserving label data

Description

This extends [forcats::fct_drop()] to natively work across a data.frame and replaces [base::droplevels()].

Usage

fct_drop(x, ...)

## S3 method for class 'data.frame'
fct_drop(x, ...)

## S3 method for class 'factor'
fct_drop(x, ...)

Arguments

x

Factor to drop unused levels

...

Other arguments passed down to method.

Examples

mtcars |>
  numchar2fct() |>
  fct_drop()
mtcars |>
  numchar2fct() |>
  dplyr::mutate(vs = fct_drop(vs))

REDCapCAST documentation built on April 4, 2025, 3:18 a.m.