← Back to all sparks
I

incase

ANALYTICS
Velocity0.0

R package incase by rossellhayes — release notes from GitHub.

A safer case_when that keeps hardening its guarantees while realigning to tidyverse naming.

data-wranglingrecodingtidyverseapi-deprecationtype-safetyr-package
Current state
incase supplies in_case(), switch_case(), grep_case() and fn_case() as vectorised recoding functions in the dplyr::case_when idiom, with _fct and _list variants that return factors or lists instead of forcing atomic type conversion. The 0.4.0 release deprecates the undotted preserve, default and ordered arguments in favour of dotted forms, starting a removal clock, and adds .exhaustive to error on unmatched inputs.
Where it's heading
The arc is consistently toward catching recoding mistakes at the call site rather than letting them pass silently. Early releases broadened how a match can be expressed — pattern matching, function application, factor and list returns. Recent work has shifted to guarantees about the result: correct factor level ordering relative to .default, and now an exhaustiveness check. Notably 0.4.0 reverses the 0.3.2 decision to accept arguments with or without dots, trading that flexibility for namespace safety against user-supplied case names.
Prediction
The deprecation warnings introduced in 0.4.0 point to a follow-up release that removes the undotted arguments outright. Whether .exhaustive eventually becomes the default is unclear from these entries.

Recent moves

  1. 11mo ago

    Dotted arguments and an .exhaustive matching check

    Undotted preserve/default/ordered arguments are deprecated in favour of dotted forms and now warn, while .exhaustive adds an opt-in error when input elements match no case. The .default argument's position now determines where the default value lands in factor levels, and grep_case() accepts vectors on the left-hand side.

    View source ↗
  2. 2y ago

    Dotted and undotted arguments both accepted

    Arguments become accepted with or without leading dots and default is factored into output class resolution — the flexibility 0.4.0 later walks back. Also fixes replacement failing when a condition held only NA and FALSE values.

    View source ↗
  3. 5y ago

    Fix NULL return when no condition matches

    Fixes *_case() returning NULL when no condition was TRUE, and adds tibble to Suggests. A correctness patch on the edge case, not a change in what the functions do.

    View source ↗
  4. 5y ago

    Factor and list return families arrive

    The *_case_fct() and *_case_list() families arrive, returning factors ordered by case statement and lists that survive without automatic type coercion. This is where the package stopped being a case_when clone and started solving the return-type problem that motivates it.

    View source ↗
  5. 5y ago

    Drop unused stats import to clear a check NOTE

    Removes an unnecessary stats import to clear a check NOTE and picks up a newer plu for error messages. Packaging housekeeping.

    View source ↗
  6. 5y ago

    Pattern and function-based matching families added

    grep_case() adds pattern matching and fn_case()/fn_switch_case() let an arbitrary function build the comparison vectors. These expanded matching beyond exact equality and set up the family structure the later releases build on.

    View source ↗