checkr
checkr: An R package for Assertive Programming - Published in JOSS (2018)
Science Score: 93.0%
This score indicates how likely this project is to be science-related based on various indicators:
-
○CITATION.cff file
-
✓codemeta.json file
Found codemeta.json file -
✓.zenodo.json file
Found .zenodo.json file -
✓DOI references
Found 4 DOI reference(s) in README and JOSS metadata -
✓Academic publication links
Links to: joss.theoj.org -
○Committers with academic emails
-
○Institutional organization owner
-
✓JOSS paper metadata
Published in Journal of Open Source Software
Keywords
assertion
checkr
rstats
Keywords from Contributors
ecotoxicology
species-sensitivity-distribution
Last synced: 6 months ago
·
JSON representation
Repository
An R package of assertive functions to check the properties of common R objects.
Basic Info
- Host: GitHub
- Owner: poissonconsulting
- License: other
- Language: R
- Default Branch: main
- Homepage: https://poissonconsulting.github.io/checkr/
- Size: 3.5 MB
Statistics
- Stars: 13
- Watchers: 3
- Forks: 1
- Open Issues: 0
- Releases: 7
Topics
assertion
checkr
rstats
Created about 8 years ago
· Last pushed 9 months ago
Metadata Files
Readme
Changelog
Contributing
License
Code of conduct
Support
README.Rmd
---
output: github_document
---
```{r setup, include = FALSE}
knitr::opts_chunk$set(
collapse = TRUE,
comment = "#>",
fig.path = "man/figures/README-",
out.width = "100%"
)
```
[](https://lifecycle.r-lib.org/articles/stages.html#superseded)
[](https://github.com/poissonconsulting/checkr/actions/workflows/R-CMD-check.yaml)
[](https://app.codecov.io/gh/poissonconsulting/checkr)
[](https://opensource.org/license/mit/)
[](https://doi.org/10.21105/joss.00624)
# checkr
`checkr` has been superseded by the [`chk`](https://github.com/poissonconsulting/chk) package.
`checkr` is a light-weight R package of expressive, assertive, pipe-friendly functions to check the properties of common R objects.
In the case of failure the functions, which are designed to be used in scripts and packages,
issue informative error messages.
For an overview of the functions see the `checkr-naming` vignette and for a comparison with similar packages see the `assertive-programming` vignette.
## Demonstration
The following code demonstrates the `check_data()` function
```{r, error = TRUE}
library(checkr)
# the starwars data frame in the dplyr package fails many of these checks
check_data(dplyr::starwars, values = list(
height = c(66L, 264L),
name = "",
mass = c(20,1358, NA),
hair_color = c("blond", "brown", "black", NA),
gender = c("male", "female", "hermaphrodite", "none", NA)),
order = TRUE, nrow = c(81, 84), key = "hair_color", error = FALSE)
```
## Syntax
`checkr` uses objects to check
the values of other objects using an elegant and expressive syntax.
#### Class
To check the class simply pass an object of the desired class.
```{r, error = TRUE}
y <- c(2,1,0,1,NA)
check_vector(y, values = numeric(0))
check_vector(y, values = integer(0))
```
#### Missing Values
To check that a vector does not include missing values pass a single non-missing value (of the correct class).
```{r, error = TRUE}
check_vector(y, 1)
```
To allow it to include missing values include a missing value.
```{r}
check_vector(y, c(1, NA))
```
And to check that it only includes missing values only pass a missing value (of the correct class)
```{r, error = TRUE}
check_vector(y, NA_real_)
```
#### Range
To check the range of a vector pass two non-missing values (as well as the missing value if required).
```{r, error = TRUE}
check_vector(y, c(0, 2, NA))
check_vector(y, c(-1, -10, NA))
```
#### Specific Values
To check the vector only includes specific values pass three or more non-missing values or
set `only = TRUE`.
```{r, error = TRUE}
check_vector(y, c(0, 1, 2, NA))
check_vector(y, c(1, 1, 2, NA))
check_vector(y, c(1, 2, NA), only = TRUE)
```
## Naming Objects
By default, the name of an object is determined from the function call.
```{r, error=TRUE}
check_vector(list(x = 1))
```
This simplifies things but results in less informative error messages when used in a pipe.
```{r, error = TRUE}
library(magrittr)
y %>% check_list()
```
The argument `x_name` can be used to override the name.
```{r, error = TRUE}
y %>% check_list(x_name = "y")
```
## Scalars
The four wrapper functions
`check_lgl()`, `check_int()`, `check_dbl()` and `check_str()` check whether an object
is an attribute-less non-missing scalar logical (flag), integer, double (number) or character (string).
They are really useful for checking the types of arguments in functions
```{r, error = TRUE}
fun <- function(x) { check_lgl(x)}
fun(x = NA)
fun(x = TRUE)
fun(x = 1)
```
Additional scalar wrappers are `check_date()` and `check_dttm()` for scalar Date and POSIXct objects.
Alternatively you can roll your own using the more general `check_scalar()` function.
## Installation
To install the latest development version from [r-universe](https://poissonconsulting.r-universe.dev/checkr).
```r
install.packages("checkr", repos = c("https://poissonconsulting.r-universe.dev", "https://cloud.r-project.org"))
```
To install the latest development version from [GitHub](https://github.com/poissonconsulting/checkr)
```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/checkr")
```
## Citation
```{r, comment="", echo=FALSE}
citation(package = "checkr")
```
## Contribution
Please report any [issues](https://github.com/poissonconsulting/checkr/issues).
[Pull requests](https://github.com/poissonconsulting/checkr/pulls) are always welcome.
## Code of Conduct
Please note that the checkr 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
Owner
- Name: Poisson Consulting Ltd.
- Login: poissonconsulting
- Kind: organization
- Email: software@poissonconsulting.ca
- Location: Nelson, BC, Canada
- Website: http://www.poissonconsulting.ca
- Repositories: 68
- Profile: https://github.com/poissonconsulting
Computational Biology and Statistical Ecology
JOSS Publication
checkr: An R package for Assertive Programming
Published
March 27, 2018
Volume 3, Issue 23, Page 624
Tags
programming assertiveGitHub Events
Total
- Push event: 6
Last Year
- Push event: 6
Committers
Last synced: 7 months ago
Top Committers
| Name | Commits | |
|---|---|---|
| Joe Thorley | j****e@p****a | 196 |
| Duncan Kennedy | d****n@p****a | 19 |
| Ayla Pearson | a****a@p****a | 19 |
| Evan | e****i@g****m | 9 |
| Nadine Hussein | n****3@g****m | 8 |
| Mowahid Latif | m****f@M****l | 2 |
| Arfon Smith | a****n | 1 |
Committer Domains (Top 20 + Academic)
Issues and Pull Requests
Last synced: 6 months ago
All Time
- Total issues: 11
- Total pull requests: 14
- Average time to close issues: 5 months
- Average time to close pull requests: 3 days
- Total issue authors: 4
- Total pull request authors: 5
- Average comments per issue: 1.91
- Average comments per pull request: 0.64
- Merged pull requests: 12
- Bot issues: 0
- Bot pull requests: 0
Past Year
- Issues: 0
- Pull requests: 1
- Average time to close issues: N/A
- Average time to close pull requests: 21 days
- Issue authors: 0
- Pull request authors: 1
- Average comments per issue: 0
- Average comments per pull request: 7.0
- Merged pull requests: 1
- Bot issues: 0
- Bot pull requests: 0
Top Authors
Issue Authors
- joethorley (6)
- sebdalgarno (3)
- joelnitta (1)
- gvwilson (1)
Pull Request Authors
- nadinehussein (8)
- dunkenwg (2)
- aylapear (2)
- MowahidLatif (2)
- arfon (1)
Top Labels
Issue Labels
Pull Request Labels
Packages
- Total packages: 1
-
Total downloads:
- cran 330 last-month
- Total docker downloads: 34
- Total dependent packages: 11
- Total dependent repositories: 4
- Total versions: 6
- Total maintainers: 1
cran.r-project.org: checkr
Check the Properties of Common R Objects
- Homepage: https://github.com/poissonconsulting/checkr
- Documentation: http://cran.r-project.org/web/packages/checkr/checkr.pdf
- License: MIT + file LICENSE
- Status: removed
-
Latest release: 0.5.0
published almost 7 years ago
Rankings
Dependent packages count: 4.9%
Dependent repos count: 15.0%
Stargazers count: 15.5%
Average: 16.9%
Forks count: 21.5%
Downloads: 27.5%
Maintainers (1)
Last synced:
6 months ago
Dependencies
DESCRIPTION
cran
- R >= 3.5 depends
- err * imports
- lifecycle * imports
- assertthat * suggests
- checkmate * suggests
- chk * suggests
- covr * suggests
- datasets * suggests
- dplyr * suggests
- hms * suggests
- knitr * suggests
- magrittr * suggests
- rlang * suggests
- rmarkdown * suggests
- testthat * suggests
- units * suggests
.github/workflows/R-CMD-check.yaml
actions
- 8398a7/action-slack v3.0.0 composite
- actions/cache v2 composite
- actions/checkout v2 composite
- actions/upload-artifact master composite
- r-lib/actions/setup-pandoc master composite
- r-lib/actions/setup-r master composite
.github/workflows/coverage.yaml
actions
- 8398a7/action-slack v3.0.0 composite
- actions/cache v1 composite
- actions/checkout v2 composite
- r-lib/actions/setup-pandoc master composite
- r-lib/actions/setup-r master composite
.github/workflows/pkgdown.yaml
actions
- 8398a7/action-slack v3.0.0 composite
- actions/cache v2 composite
- actions/checkout v2 composite
- r-lib/actions/setup-pandoc master composite
- r-lib/actions/setup-r master composite
