https://github.com/poissonconsulting/chk
An R package for developers to check user-supplied function arguments
https://github.com/poissonconsulting/chk
chk cran rstats
Last synced: 7 months ago
JSON representation
An R package for developers to check user-supplied function arguments
- Host: GitHub
- URL: https://github.com/poissonconsulting/chk
- Owner: poissonconsulting
- License: other
- Created: 2019-07-31T16:42:59.000Z (over 6 years ago)
- Default Branch: main
- Last Pushed: 2025-01-28T00:48:18.000Z (9 months ago)
- Last Synced: 2025-03-28T21:03:40.507Z (7 months ago)
- Topics: chk, cran, rstats
- Language: R
- Homepage: https://poissonconsulting.github.io/chk/
- Size: 8.53 MB
- Stars: 48
- Watchers: 3
- Forks: 5
- Open Issues: 4
-
Metadata Files:
- Readme: README.Rmd
- Changelog: NEWS.md
- Contributing: .github/CONTRIBUTING.md
- License: LICENSE
- Code of conduct: .github/CODE_OF_CONDUCT.md
- Support: .github/SUPPORT.md
Awesome Lists containing this project
- jimsghstars - poissonconsulting/chk - An R package for developers to check user-supplied function arguments (R)
README
---
output: github_document
---
```{r, include = FALSE}
knitr::opts_chunk$set(
collapse = TRUE,
comment = "#>",
fig.path = "man/figures/README-",
out.width = "100%"
)
```
# chk 
[](https://lifecycle.r-lib.org/articles/stages.html#stable)
[](https://github.com/poissonconsulting/chk/actions/workflows/R-CMD-check.yaml)
[](https://app.codecov.io/gh/poissonconsulting/chk)
[](https://opensource.org/license/mit)
[](https://cran.r-project.org/package=chk)

`chk` is an R package for developers to check user-supplied function arguments.
It is designed to be simple, customizable and fast.
## Demonstration
`chk` provides simple commonly used checks as (`chk_` functions) which can be combined together for more complex checking.
```{r, error = TRUE}
library(chk)
y <- "a"
chk_string(y)
chk_flag(y)
data <- data.frame(x = 1:2)
chk_range(nrow(data), c(3, 8))
```
Or used inside functions to test user-provided arguments.
```{r, error = TRUE}
my_fun <- function(x) {
chk_flag(x)
x
}
my_fun(TRUE)
my_fun(NA)
```
Error messages follow the [tidyverse style guide](https://style.tidyverse.org/errors.html) while the errors themselves are [rlang errors](https://rlang.r-lib.org/reference/abort.html) of class `chk_error`.
## Information
For more information see the [Get Started](https://poissonconsulting.github.io/chk/articles/chk.html) vignette.
## Installation
### Release
To install the release version from [CRAN](https://CRAN.R-project.org/package=chk).
```r
install.packages("chk")
```
The website for the release version is at .
### Development
To install the development version from [GitHub](https://github.com/poissonconsulting/chk)
```r
# install.packages("remotes")
remotes::install_github("poissonconsulting/chk")
```
or from [r-universe](https://poissonconsulting.r-universe.dev/chk).
```r
install.packages("chk", repos = c("https://poissonconsulting.r-universe.dev", "https://cloud.r-project.org"))
```
## Inspiration
- [datacheckr](https://github.com/poissonconsulting/datacheckr/)
- [checkr](https://github.com/poissonconsulting/checkr/)
- [err](https://github.com/poissonconsulting/err/)
- [testthat](https://github.com/r-lib/testthat/)
## Contribution
Please report any [issues](https://github.com/poissonconsulting/chk/issues).
[Pull requests](https://github.com/poissonconsulting/chk/pulls) are always welcome.
## Code of Conduct
Please note that the chk project is released with a [Contributor Code of Conduct](https://contributor-covenant.org/version/2/0/CODE_OF_CONDUCT.html). By contributing to this project, you agree to abide by its terms.