mllg / checkmate

Fast and versatile argument checks
https://mllg.github.io/checkmate/
Other
265 stars 30 forks source link

[feature request] pipe friendly assert/test statements #247

Open vorpalvorpal opened 1 year ago

vorpalvorpal commented 1 year ago

At present the following works:

library(tidyverse)
library(checkmate)

tibble(a = c(1,2)) |>
  mutate(a = assert_numeric(a)) |>
  # continue with pipe

However, it feels like a waste to replace a with the output of assert_numeric (which is of course equal to a). Would it be possible to instead have a dplyr style function along the lines of:

tibble(a = c(1,2)) |>
  check(test_numeric(a)) |>
  # continue with pipe

where check() does dplyr style data-masking and then just returns its input (or raises an error).