exemplar | R Documentation |
This function will print a validation function that can be used to make sure that a new object looks like the input (its exemplar).
Some checks are commented out. This is because the exemplar does not meet the criteria (eg. no duplicate values) or the checks are too specific to be used by default (range checks). The intention is that users will modify the validation functions to meet their needs before placing them in pipelines and scripts.
The functions produced by exemplar
require at least R 3.5 (due to
improvements made to \link{stopifnot}
but otherwise requires no
dependencies. That is, exemplar
generates functions that do not need
exemplar
or any other packages to run.
exemplar(
x,
...,
.function_suffix = NULL,
.enable_range_assertions = FALSE,
.enable_deviance_assertions = FALSE,
.allowed_deviance = 4
)
x |
The object to use as the exemplar of the validation function. |
... |
Additional arguments used when building the assertions. Currently
this is only used to apply validation to only certain columns in a data
frame. This uses |
.function_suffix |
By default the generated function will be named after
the input, eg. |
.enable_range_assertions |
Assertions for numeric columns/vectors will
include range assertions, to ensure that any new data is within the range
of the exemplar. These assertions will be commented out by default, unless
the argument to this parameter is |
.enable_deviance_assertions |
Assertions for numeric columns/vectors
will include deviance assertions, to ensure that any new data is within a
number of standard deviations of the mean of the exemplar, as configured by
|
.allowed_deviance |
Configures the number of standard deviations from
the mean that new data is allowed to be. The deviance assertions are
commented out by default unless |
exemplar(mtcars)
exemplar(mtcars$gear)
exemplar(mtcars, -cyl)
exemplar(mtcars, starts_with("d"))
exemplar(mtcars, .function_suffix = "my_data")
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.