knitr::opts_chunk$set( collapse = TRUE, comment = "##", fig.path = "README-", error = TRUE ) library(vetr)
vetr in FunctionsIf you are vetting function inputs, you can use the vetr function, which works
just like vet except that it is streamlined for use within functions:
fun <- function(x, y) { vetr(numeric(1L), logical(1L)) TRUE # do work... } fun(1:2, "foo") fun(1, "foo")
vetr automatically matches the vetting expressions to the corresponding
arguments and fetches the argument values from the function environment.
See vignette for additional details on how the vetr function works.
vetr vignette, ?vet, ?vetr, example(vet), example(vetr).alike vignette, ?alike, and example(alike) for discussion of
templates.vetr is still in development, although most of the features are considered
mature. The most likely area of change is the treatment of function and
language templates (e.g. alike(sum, max)), and more flexible treatment of
list templates (e.g. in future lists may be allowed to be different lengths so
long as every named element in the template exists in the object).
This package is available on CRAN:
install.packages('vetr')
It has no runtime dependencies.
For the development version use
remotes::install_github('brodieg/vetr@development') or:
f.dl <- tempfile() f.uz <- tempfile() github.url <- 'https://github.com/brodieG/vetr/archive/development.zip' download.file(github.url, f.dl) unzip(f.dl, exdir=f.uz) install.packages(file.path(f.uz, 'vetr-development'), repos=NULL, type='source') unlink(c(f.dl, f.uz))
The master branch typically mirrors CRAN and should be stable.
There are many alternatives available to vetr. We do a survey of the
following in our parameter validation functions review:
Thank you to:
all_bw to
compete with his own package checkmate.vetr only worked with function arguments), which I took from
ensurer.Brodie Gaslam is a hobbyist programmer based on the US East Coast.
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.