https://github.com/chris-prener/disputer

R package for validating arguments passed to function parameters

https://github.com/chris-prener/disputer

Science Score: 26.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
  • Academic publication links
  • Academic email domains
  • Institutional organization owner
  • JOSS paper metadata
  • Scientific vocabulary similarity
    Low similarity (19.9%) to scientific vocabulary
Last synced: 10 months ago · JSON representation

Repository

R package for validating arguments passed to function parameters

Basic Info
Statistics
  • Stars: 0
  • Watchers: 1
  • Forks: 0
  • Open Issues: 5
  • Releases: 0
Created over 1 year ago · Last pushed about 1 year ago
Metadata Files
Readme Changelog Contributing License Code of conduct

README.Rmd

---
output: github_document
---



```{r, include = FALSE}
knitr::opts_chunk$set(
  collapse = TRUE,
  comment = "#>",
  fig.path = "man/figures/README-",
  out.width = "100%"
)
```

# disputeR

[![R build status](https://github.com/chris-prener/disputeR/workflows/R-CMD-check/badge.svg)](https://github.com/chris-prener/disputeR/actions)

The goal of `disputeR` is to easily implement unit tests within functions and Shiny modules. Unlike other packages that provide frameworks for developing these tests, `disputeR` takes a different approach, offering pre-built unit tests that can easily be dropped into functions and test for basic requirements, like class, length, and common values used in function writing (such as `NULL`). These tests return informative error messages that follow the [`tidyverse` style guide's recommendations](https://style.tidyverse.org/errors.html).

## Installation

You can install the development version of `disputeR` from [GitHub](https://github.com/) with:

``` r
# install.packages("remotes")
remotes::install_github("chris-prener/disputeR")
```

## Basic Usage

The following example creates a simple function for squaring a numeric value, which is passed to the function using the parameter `x`. Two `disputeR` functions are added before squaring `x`. The first, `dis_not_missing()`, evaluates `x` to ensure the parameter is not skipped by the user. The second, `dis_numeric()`, applies a number of checks to `x`.

```{r}
## load package
library(disputeR)

## define example function
example <- function(x){

   ## check inputs with disputeR
   dis_not_missing(.f = missing(x))
   dis_numeric(x, null_valid = FALSE)

   ## square
   out <- x^2

   ## return output
   return(out)

}
```

The checks `dis_numeric()` applies include default settings that require a scalar input (i.e. `length(x) == 1`) and do not allow `NA`, `NaN`, `Inf`, or `-Inf`. Each of these can be enabled using the parameters for `dis_numeric()` at the function author's discretion. In addition, we enforce a requirement that `x` cannot be `NULL`.

In the case of the following example, `2` is a valid input to `example()` and the function executes without error:

```{r}
example(x = 2)
```

However, if the user does not specify the `x` argument, an informative error message is returned along with instructions for how to rectify the issue:

```{r, error = TRUE}
example()
```

Likewise, if `x` is incorrectly specified (such as with a `class(x) == character` value), a similar message along with instructions for fixing the error is returned:

```{r, error = TRUE}
example(x = "test")
```

## Additional Resources
Check out `disputeR`'s [website](https://chris-prener.github.io/disputeR/) for additional examples as well as tips for developing with `disputeR`.

## Code of Conduct
  
Please note that the disputeR project is released with a [Contributor Code of Conduct](https://contributor-covenant.org/version/2/1/CODE_OF_CONDUCT.html). By contributing to this project, you agree to abide by its terms.

Owner

  • Name: Chris Prener
  • Login: chris-prener
  • Kind: user
  • Location: St. Louis, MO
  • Company: Pfizer

Director, Vaccines RWE Biocurator Scientist 🚀 and Sociologist interested in vaccines, health outcomes and disparities, geospatial data science, and demography

GitHub Events

Total
  • Issues event: 7
  • Watch event: 1
  • Issue comment event: 2
  • Push event: 34
  • Create event: 3
Last Year
  • Issues event: 7
  • Watch event: 1
  • Issue comment event: 2
  • Push event: 34
  • Create event: 3

Issues and Pull Requests

Last synced: over 1 year ago

All Time
  • Total issues: 0
  • Total pull requests: 0
  • Average time to close issues: N/A
  • Average time to close pull requests: N/A
  • Total issue authors: 0
  • Total pull request authors: 0
  • Average comments per issue: 0
  • Average comments per pull request: 0
  • Merged pull requests: 0
  • Bot issues: 0
  • Bot pull requests: 0
Past Year
  • Issues: 0
  • Pull requests: 0
  • Average time to close issues: N/A
  • Average time to close pull requests: N/A
  • Issue authors: 0
  • Pull request authors: 0
  • Average comments per issue: 0
  • Average comments per pull request: 0
  • Merged pull requests: 0
  • Bot issues: 0
  • Bot pull requests: 0
Top Authors
Issue Authors
  • chris-prener (5)
Pull Request Authors
Top Labels
Issue Labels
Pull Request Labels

Dependencies

.github/workflows/R-CMD-check.yaml actions
  • actions/checkout v4 composite
  • r-lib/actions/check-r-package v2 composite
  • r-lib/actions/setup-r v2 composite
  • r-lib/actions/setup-r-dependencies v2 composite
.github/workflows/pkgdown.yml actions
  • JamesIves/github-pages-deploy-action 4.1.4 composite
  • actions/checkout v2 composite
  • r-lib/actions/setup-pandoc v2 composite
  • r-lib/actions/setup-r v2 composite
  • r-lib/actions/setup-r-dependencies v2 composite
DESCRIPTION cran
  • cli * imports
  • rlang * imports