Overview
Assertive programming doesn’t have to be ugly. If ultra-fast checks aren’t your top priority, prettycheck is for you. This R package provides a set of functions that produce pretty and informative error messages, primarily using the cli package from r-lib.
prettycheck adheres to tidyverse principles and seamlessly integrates with the tidyverse ecosystem.
Need faster assertive programming? Try checkmate. Since prettycheck uses the same structural approach to checks, transitioning between packages is straightforward. You can also use both packages together without conflicts.
Installation
You can install prettycheck using the remotes package:
remotes::install_github("danielvartan/prettycheck")Usage
Like checkmate, prettycheck includes four family of functions: test_*(), check_*(), assert_*(), and expect_*().
The test_*() functions return a logical flag; the check_*() functions throw a warning message as a string if the condition is not met; and the assert_*() and expect_*() functions throw an error if the condition is not met. If the condition is met, check_*() returns a logical flag; assert_*() and expect_*() functions return the input object invisibly.
Here are some of the functions available:
-
assert_color(): Assert if an argument is a valid color -
check_duration()test_duration()assert_duration(): Check if an argument is aDurationobject -
check_hms()test_hms()assert_hms(): Check if an argument is ahmsobject -
check_identical()test_identical()assert_identical(): Check if multiple objects are identical -
check_interval()test_interval()assert_interval(): Check if an argument is anIntervalobject -
check_length()test_length()assert_length(): Check if an argument has a specific length -
check_period()test_period()assert_period(): Check if an argument is aPeriodobject -
check_pick()test_pick()assert_pick(): Check how many arguments were picked -
check_posixt()test_period()assert_period(): Check if an argument is aPOSIXtobject -
check_temporaltest_temporal()assert_temporal(): Check if an argument is a temporal object
Click here to see the full list of functions.
Contributing
Contributions are welcome, including bug reports. Take a moment to review the Guidelines for Contributing.
Become an prettycheck supporter!
Click here to make a donation. Please indicate the prettycheck package in your donation message.
