checkr

checkr: An R package for Assertive Programming - Published in JOSS (2018)

https://github.com/poissonconsulting/checkr

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
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%"
)
```


[![Lifecycle: superseded](https://img.shields.io/badge/lifecycle-superseded-blue.svg)](https://lifecycle.r-lib.org/articles/stages.html#superseded)
[![R-CMD-check](https://github.com/poissonconsulting/checkr/actions/workflows/R-CMD-check.yaml/badge.svg)](https://github.com/poissonconsulting/checkr/actions/workflows/R-CMD-check.yaml)
[![Codecov test coverage](https://codecov.io/gh/poissonconsulting/checkr/graph/badge.svg)](https://app.codecov.io/gh/poissonconsulting/checkr)
[![License: MIT](https://img.shields.io/badge/License-MIT-green.svg)](https://opensource.org/license/mit/)
[![JOSS](http://joss.theoj.org/papers/10.21105/joss.00624/status.svg)](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

Computational Biology and Statistical Ecology

JOSS Publication

checkr: An R package for Assertive Programming
Published
March 27, 2018
Volume 3, Issue 23, Page 624
Authors
Joe Thorley ORCID
Poisson Consulting, Nelson, British Columbia
Editor
Arfon Smith ORCID
Tags
programming assertive

GitHub Events

Total
  • Push event: 6
Last Year
  • Push event: 6

Committers

Last synced: 7 months ago

All Time
  • Total Commits: 254
  • Total Committers: 7
  • Avg Commits per committer: 36.286
  • Development Distribution Score (DDS): 0.228
Past Year
  • Commits: 20
  • Committers: 2
  • Avg Commits per committer: 10.0
  • Development Distribution Score (DDS): 0.05
Top Committers
Name Email 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

  • Versions: 6
  • Dependent Packages: 11
  • Dependent Repositories: 4
  • Downloads: 330 Last month
  • Docker Downloads: 34
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