rlang-conditions
Condition Handling in R Packages
When to Use What
| Task | Use |
|---|---|
| Throw formatted error | cli_abort() with message and bullets |
| Throw formatted warning | cli_warn() with message and bullets |
| Display informative message | cli_inform() with message and bullets |
| Show correct function in error | call = caller_env() argument |
| Get argument name dynamically | arg = caller_arg(x) in input checkers |
| Catch and rethrow with context | try_fetch() with parent = cnd |
| Take ownership of low-level error | try_fetch() with parent = NA |
| Test error messages | expect_snapshot(error = TRUE, ...) |
CLI Conditions Essentials
Use cli_abort(), cli_warn(), and cli_inform() instead of base R's stop(), warning(), and message() for formatted condition messages.
More from jsperger/llm-r-skills
ggplot2
Use when working with R ggplot2 package, especially ggplot2 4.0+ features. Covers S7 migration (@ property access), theme defaults with ink/paper/accent, element_geom(), from_theme(), theme shortcuts (theme_sub_*), palette themes, labels with dictionary/attributes, discrete scale improvements (palette, continuous.limits, minor_breaks, sec.axis), position aesthetics (nudge_x/nudge_y, order), facet_wrap dir/space/layout, boxplot/violin/label styling, stat_manual(), stat_connect(), coord reversal.
41targets-pipelines
>
12hardhat
>
11tidy-evaluation
>
11tidymodels-overview
This skill should be used when working with R tidymodels packages, including when the user asks to "create a tidymodels workflow", "build a recipe", "tune a model", "use parsnip", "set up resampling", "create a workflow_set", "compare models", "stack models", or mentions tidymodels packages like recipes, parsnip, workflows, workflowsets, tune, rsample, yardstick, or stacks. Provides ecosystem context before package-specific skills.
11metaprogramming
>
10