forked from poissonconsulting/chk
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathREADME.Rmd
98 lines (69 loc) · 3.19 KB
/
README.Rmd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
---
output: github_document
---
<!-- README.md is generated from README.Rmd. Please edit that file -->
```{r, include = FALSE}
knitr::opts_chunk$set(
collapse = TRUE,
comment = "#>",
fig.path = "man/figures/README-",
out.width = "100%"
)
```
# chk <img src="man/figures/logo.png" style="float: right;" />
<!-- badges: start -->
[](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)

<!-- badges: end -->
`chk` is an R package for developers to check user-supplied function arguments.
It is designed to be simple, customizable and fast.
## Installation
To install the latest release version from CRAN.
```r
install.packages("chk")
```
To install the latest development version 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"))
```
To install the latest development version from [GitHub](https://github.com/poissonconsulting/chk)
```r
# install.packages("pak", repos = sprintf("https://r-lib.github.io/p/pak/stable/%s/%s/%s", .Platform$pkgType, R.Version()$os, R.Version()$arch))
pak::pak("poissonconsulting/chk")
```
## 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/error-messages.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.
## 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.