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.
Usage
exemplar(
x,
...,
.function_suffix = NULL,
.enable_range_assertions = FALSE,
.enable_deviance_assertions = FALSE,
.allowed_deviance = 4
)
Arguments
- 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
tidyselect
functions. Refer todplyr
package for more information.- .function_suffix
By default the generated function will be named after the input, eg.
exemplar(mtcars)
will generate a function namedvalidate_mtcars
. This parameter allows overriding the suffix, eg.exemplar(mtcars, .function_suffix = "my_data")
will generate a function namedvalidate_my_data
.- .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
TRUE
.- .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
. These assertions will be commented out by default, unless the argument to this parameter isTRUE
.- .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
.enable_deviance_assertions
is set toTRUE
. The.allowed_deviance
defaults to 4, such that new data is within 4 standard deviations of the mean based on the statistical properties of the exemplar.
Examples
exemplar(mtcars)
#> validate_mtcars <- function(data) {
#> stopifnot(exprs = {
#> is.data.frame(data)
#> identical(colnames(data), c("mpg", "cyl", "disp", "hp", "drat", "wt", "qsec", "vs", "am", "gear", "carb"))
#>
#> "mpg" %in% colnames(data)
#> is.double(data[["mpg"]])
#> !any(is.na(data[["mpg"]]) | is.null(data[["mpg"]]))
#> # Duplicate values were detected so this assertion has been disabled:
#> # !any(duplicated(data[["mpg"]]))
#> min(data[["mpg"]], na.rm = TRUE) > 0 # all positive
#> # (Un)comment or modify the below range assertions if needed:
#> # max(data[["mpg"]], na.rm = TRUE) <= 33.9
#> # 10.4 <= min(data[["mpg"]], na.rm = TRUE)
#> # (Un)comment or modify the below deviance assertions if needed.
#> # The mean is 20.09 and the standard deviation is 6.03:
#> # max(data[["mpg"]], na.rm = TRUE) <= 20.09 + 4 * 6.03
#> # 20.09 - 4 * 6.03 <= max(data[["mpg"]], na.rm = TRUE)
#>
#> "cyl" %in% colnames(data)
#> is.double(data[["cyl"]])
#> !any(is.na(data[["cyl"]]) | is.null(data[["cyl"]]))
#> # Duplicate values were detected so this assertion has been disabled:
#> # !any(duplicated(data[["cyl"]]))
#> min(data[["cyl"]], na.rm = TRUE) > 0 # all positive
#> # (Un)comment or modify the below range assertions if needed:
#> # max(data[["cyl"]], na.rm = TRUE) <= 8
#> # 4 <= min(data[["cyl"]], na.rm = TRUE)
#> # (Un)comment or modify the below deviance assertions if needed.
#> # The mean is 6.19 and the standard deviation is 1.79:
#> # max(data[["cyl"]], na.rm = TRUE) <= 6.19 + 4 * 1.79
#> # 6.19 - 4 * 1.79 <= max(data[["cyl"]], na.rm = TRUE)
#>
#> "disp" %in% colnames(data)
#> is.double(data[["disp"]])
#> !any(is.na(data[["disp"]]) | is.null(data[["disp"]]))
#> # Duplicate values were detected so this assertion has been disabled:
#> # !any(duplicated(data[["disp"]]))
#> min(data[["disp"]], na.rm = TRUE) > 0 # all positive
#> # (Un)comment or modify the below range assertions if needed:
#> # max(data[["disp"]], na.rm = TRUE) <= 472
#> # 71.1 <= min(data[["disp"]], na.rm = TRUE)
#> # (Un)comment or modify the below deviance assertions if needed.
#> # The mean is 230.72 and the standard deviation is 123.94:
#> # max(data[["disp"]], na.rm = TRUE) <= 230.72 + 4 * 123.94
#> # 230.72 - 4 * 123.94 <= max(data[["disp"]], na.rm = TRUE)
#>
#> "hp" %in% colnames(data)
#> is.double(data[["hp"]])
#> !any(is.na(data[["hp"]]) | is.null(data[["hp"]]))
#> # Duplicate values were detected so this assertion has been disabled:
#> # !any(duplicated(data[["hp"]]))
#> min(data[["hp"]], na.rm = TRUE) > 0 # all positive
#> # (Un)comment or modify the below range assertions if needed:
#> # max(data[["hp"]], na.rm = TRUE) <= 335
#> # 52 <= min(data[["hp"]], na.rm = TRUE)
#> # (Un)comment or modify the below deviance assertions if needed.
#> # The mean is 146.69 and the standard deviation is 68.56:
#> # max(data[["hp"]], na.rm = TRUE) <= 146.69 + 4 * 68.56
#> # 146.69 - 4 * 68.56 <= max(data[["hp"]], na.rm = TRUE)
#>
#> "drat" %in% colnames(data)
#> is.double(data[["drat"]])
#> !any(is.na(data[["drat"]]) | is.null(data[["drat"]]))
#> # Duplicate values were detected so this assertion has been disabled:
#> # !any(duplicated(data[["drat"]]))
#> min(data[["drat"]], na.rm = TRUE) > 0 # all positive
#> # (Un)comment or modify the below range assertions if needed:
#> # max(data[["drat"]], na.rm = TRUE) <= 4.93
#> # 2.76 <= min(data[["drat"]], na.rm = TRUE)
#> # (Un)comment or modify the below deviance assertions if needed.
#> # The mean is 3.6 and the standard deviation is 0.53:
#> # max(data[["drat"]], na.rm = TRUE) <= 3.6 + 4 * 0.53
#> # 3.6 - 4 * 0.53 <= max(data[["drat"]], na.rm = TRUE)
#>
#> "wt" %in% colnames(data)
#> is.double(data[["wt"]])
#> !any(is.na(data[["wt"]]) | is.null(data[["wt"]]))
#> # Duplicate values were detected so this assertion has been disabled:
#> # !any(duplicated(data[["wt"]]))
#> min(data[["wt"]], na.rm = TRUE) > 0 # all positive
#> # (Un)comment or modify the below range assertions if needed:
#> # max(data[["wt"]], na.rm = TRUE) <= 5.424
#> # 1.513 <= min(data[["wt"]], na.rm = TRUE)
#> # (Un)comment or modify the below deviance assertions if needed.
#> # The mean is 3.22 and the standard deviation is 0.98:
#> # max(data[["wt"]], na.rm = TRUE) <= 3.22 + 4 * 0.98
#> # 3.22 - 4 * 0.98 <= max(data[["wt"]], na.rm = TRUE)
#>
#> "qsec" %in% colnames(data)
#> is.double(data[["qsec"]])
#> !any(is.na(data[["qsec"]]) | is.null(data[["qsec"]]))
#> # Duplicate values were detected so this assertion has been disabled:
#> # !any(duplicated(data[["qsec"]]))
#> min(data[["qsec"]], na.rm = TRUE) > 0 # all positive
#> # (Un)comment or modify the below range assertions if needed:
#> # max(data[["qsec"]], na.rm = TRUE) <= 22.9
#> # 14.5 <= min(data[["qsec"]], na.rm = TRUE)
#> # (Un)comment or modify the below deviance assertions if needed.
#> # The mean is 17.85 and the standard deviation is 1.79:
#> # max(data[["qsec"]], na.rm = TRUE) <= 17.85 + 4 * 1.79
#> # 17.85 - 4 * 1.79 <= max(data[["qsec"]], na.rm = TRUE)
#>
#> "vs" %in% colnames(data)
#> is.double(data[["vs"]])
#> !any(is.na(data[["vs"]]) | is.null(data[["vs"]]))
#> # Duplicate values were detected so this assertion has been disabled:
#> # !any(duplicated(data[["vs"]]))
#> min(data[["vs"]], na.rm = TRUE) >= 0 # all non-negative
#> # (Un)comment or modify the below range assertions if needed:
#> # max(data[["vs"]], na.rm = TRUE) <= 1
#> # 0 <= min(data[["vs"]], na.rm = TRUE)
#> # (Un)comment or modify the below deviance assertions if needed.
#> # The mean is 0.44 and the standard deviation is 0.5:
#> # max(data[["vs"]], na.rm = TRUE) <= 0.44 + 4 * 0.5
#> # 0.44 - 4 * 0.5 <= max(data[["vs"]], na.rm = TRUE)
#>
#> "am" %in% colnames(data)
#> is.double(data[["am"]])
#> !any(is.na(data[["am"]]) | is.null(data[["am"]]))
#> # Duplicate values were detected so this assertion has been disabled:
#> # !any(duplicated(data[["am"]]))
#> min(data[["am"]], na.rm = TRUE) >= 0 # all non-negative
#> # (Un)comment or modify the below range assertions if needed:
#> # max(data[["am"]], na.rm = TRUE) <= 1
#> # 0 <= min(data[["am"]], na.rm = TRUE)
#> # (Un)comment or modify the below deviance assertions if needed.
#> # The mean is 0.41 and the standard deviation is 0.5:
#> # max(data[["am"]], na.rm = TRUE) <= 0.41 + 4 * 0.5
#> # 0.41 - 4 * 0.5 <= max(data[["am"]], na.rm = TRUE)
#>
#> "gear" %in% colnames(data)
#> is.double(data[["gear"]])
#> !any(is.na(data[["gear"]]) | is.null(data[["gear"]]))
#> # Duplicate values were detected so this assertion has been disabled:
#> # !any(duplicated(data[["gear"]]))
#> min(data[["gear"]], na.rm = TRUE) > 0 # all positive
#> # (Un)comment or modify the below range assertions if needed:
#> # max(data[["gear"]], na.rm = TRUE) <= 5
#> # 3 <= min(data[["gear"]], na.rm = TRUE)
#> # (Un)comment or modify the below deviance assertions if needed.
#> # The mean is 3.69 and the standard deviation is 0.74:
#> # max(data[["gear"]], na.rm = TRUE) <= 3.69 + 4 * 0.74
#> # 3.69 - 4 * 0.74 <= max(data[["gear"]], na.rm = TRUE)
#>
#> "carb" %in% colnames(data)
#> is.double(data[["carb"]])
#> !any(is.na(data[["carb"]]) | is.null(data[["carb"]]))
#> # Duplicate values were detected so this assertion has been disabled:
#> # !any(duplicated(data[["carb"]]))
#> min(data[["carb"]], na.rm = TRUE) > 0 # all positive
#> # (Un)comment or modify the below range assertions if needed:
#> # max(data[["carb"]], na.rm = TRUE) <= 8
#> # 1 <= min(data[["carb"]], na.rm = TRUE)
#> # (Un)comment or modify the below deviance assertions if needed.
#> # The mean is 2.81 and the standard deviation is 1.62:
#> # max(data[["carb"]], na.rm = TRUE) <= 2.81 + 4 * 1.62
#> # 2.81 - 4 * 1.62 <= max(data[["carb"]], na.rm = TRUE)
#> })
#> invisible(TRUE)
#> }
exemplar(mtcars$gear)
#> validate_mtcars_gear <- function(data) {
#> stopifnot(exprs = {
#> is.double(data)
#> !any(is.na(data) | is.null(data))
#> # Duplicate values were detected so this assertion has been disabled:
#> # !any(duplicated(data))
#> min(data, na.rm = TRUE) > 0 # all positive
#> # (Un)comment or modify the below range assertions if needed:
#> # max(data, na.rm = TRUE) <= 5
#> # 3 <= min(data, na.rm = TRUE)
#> # (Un)comment or modify the below deviance assertions if needed.
#> # The mean is 3.69 and the standard deviation is 0.74:
#> # max(data, na.rm = TRUE) <= 3.69 + 4 * 0.74
#> # 3.69 - 4 * 0.74 <= max(data, na.rm = TRUE)
#> })
#> invisible(TRUE)
#> }
exemplar(mtcars, -cyl)
#> validate_mtcars <- function(data) {
#> stopifnot(exprs = {
#> is.data.frame(data)
#> # The data is potentially being subsetted so this assertion has been disabled:
#> # identical(colnames(data), c("mpg", "disp", "hp", "drat", "wt", "qsec", "vs", "am", "gear", "carb"))
#>
#> "mpg" %in% colnames(data)
#> is.double(data[["mpg"]])
#> !any(is.na(data[["mpg"]]) | is.null(data[["mpg"]]))
#> # Duplicate values were detected so this assertion has been disabled:
#> # !any(duplicated(data[["mpg"]]))
#> min(data[["mpg"]], na.rm = TRUE) > 0 # all positive
#> # (Un)comment or modify the below range assertions if needed:
#> # max(data[["mpg"]], na.rm = TRUE) <= 33.9
#> # 10.4 <= min(data[["mpg"]], na.rm = TRUE)
#> # (Un)comment or modify the below deviance assertions if needed.
#> # The mean is 20.09 and the standard deviation is 6.03:
#> # max(data[["mpg"]], na.rm = TRUE) <= 20.09 + 4 * 6.03
#> # 20.09 - 4 * 6.03 <= max(data[["mpg"]], na.rm = TRUE)
#>
#> "disp" %in% colnames(data)
#> is.double(data[["disp"]])
#> !any(is.na(data[["disp"]]) | is.null(data[["disp"]]))
#> # Duplicate values were detected so this assertion has been disabled:
#> # !any(duplicated(data[["disp"]]))
#> min(data[["disp"]], na.rm = TRUE) > 0 # all positive
#> # (Un)comment or modify the below range assertions if needed:
#> # max(data[["disp"]], na.rm = TRUE) <= 472
#> # 71.1 <= min(data[["disp"]], na.rm = TRUE)
#> # (Un)comment or modify the below deviance assertions if needed.
#> # The mean is 230.72 and the standard deviation is 123.94:
#> # max(data[["disp"]], na.rm = TRUE) <= 230.72 + 4 * 123.94
#> # 230.72 - 4 * 123.94 <= max(data[["disp"]], na.rm = TRUE)
#>
#> "hp" %in% colnames(data)
#> is.double(data[["hp"]])
#> !any(is.na(data[["hp"]]) | is.null(data[["hp"]]))
#> # Duplicate values were detected so this assertion has been disabled:
#> # !any(duplicated(data[["hp"]]))
#> min(data[["hp"]], na.rm = TRUE) > 0 # all positive
#> # (Un)comment or modify the below range assertions if needed:
#> # max(data[["hp"]], na.rm = TRUE) <= 335
#> # 52 <= min(data[["hp"]], na.rm = TRUE)
#> # (Un)comment or modify the below deviance assertions if needed.
#> # The mean is 146.69 and the standard deviation is 68.56:
#> # max(data[["hp"]], na.rm = TRUE) <= 146.69 + 4 * 68.56
#> # 146.69 - 4 * 68.56 <= max(data[["hp"]], na.rm = TRUE)
#>
#> "drat" %in% colnames(data)
#> is.double(data[["drat"]])
#> !any(is.na(data[["drat"]]) | is.null(data[["drat"]]))
#> # Duplicate values were detected so this assertion has been disabled:
#> # !any(duplicated(data[["drat"]]))
#> min(data[["drat"]], na.rm = TRUE) > 0 # all positive
#> # (Un)comment or modify the below range assertions if needed:
#> # max(data[["drat"]], na.rm = TRUE) <= 4.93
#> # 2.76 <= min(data[["drat"]], na.rm = TRUE)
#> # (Un)comment or modify the below deviance assertions if needed.
#> # The mean is 3.6 and the standard deviation is 0.53:
#> # max(data[["drat"]], na.rm = TRUE) <= 3.6 + 4 * 0.53
#> # 3.6 - 4 * 0.53 <= max(data[["drat"]], na.rm = TRUE)
#>
#> "wt" %in% colnames(data)
#> is.double(data[["wt"]])
#> !any(is.na(data[["wt"]]) | is.null(data[["wt"]]))
#> # Duplicate values were detected so this assertion has been disabled:
#> # !any(duplicated(data[["wt"]]))
#> min(data[["wt"]], na.rm = TRUE) > 0 # all positive
#> # (Un)comment or modify the below range assertions if needed:
#> # max(data[["wt"]], na.rm = TRUE) <= 5.424
#> # 1.513 <= min(data[["wt"]], na.rm = TRUE)
#> # (Un)comment or modify the below deviance assertions if needed.
#> # The mean is 3.22 and the standard deviation is 0.98:
#> # max(data[["wt"]], na.rm = TRUE) <= 3.22 + 4 * 0.98
#> # 3.22 - 4 * 0.98 <= max(data[["wt"]], na.rm = TRUE)
#>
#> "qsec" %in% colnames(data)
#> is.double(data[["qsec"]])
#> !any(is.na(data[["qsec"]]) | is.null(data[["qsec"]]))
#> # Duplicate values were detected so this assertion has been disabled:
#> # !any(duplicated(data[["qsec"]]))
#> min(data[["qsec"]], na.rm = TRUE) > 0 # all positive
#> # (Un)comment or modify the below range assertions if needed:
#> # max(data[["qsec"]], na.rm = TRUE) <= 22.9
#> # 14.5 <= min(data[["qsec"]], na.rm = TRUE)
#> # (Un)comment or modify the below deviance assertions if needed.
#> # The mean is 17.85 and the standard deviation is 1.79:
#> # max(data[["qsec"]], na.rm = TRUE) <= 17.85 + 4 * 1.79
#> # 17.85 - 4 * 1.79 <= max(data[["qsec"]], na.rm = TRUE)
#>
#> "vs" %in% colnames(data)
#> is.double(data[["vs"]])
#> !any(is.na(data[["vs"]]) | is.null(data[["vs"]]))
#> # Duplicate values were detected so this assertion has been disabled:
#> # !any(duplicated(data[["vs"]]))
#> min(data[["vs"]], na.rm = TRUE) >= 0 # all non-negative
#> # (Un)comment or modify the below range assertions if needed:
#> # max(data[["vs"]], na.rm = TRUE) <= 1
#> # 0 <= min(data[["vs"]], na.rm = TRUE)
#> # (Un)comment or modify the below deviance assertions if needed.
#> # The mean is 0.44 and the standard deviation is 0.5:
#> # max(data[["vs"]], na.rm = TRUE) <= 0.44 + 4 * 0.5
#> # 0.44 - 4 * 0.5 <= max(data[["vs"]], na.rm = TRUE)
#>
#> "am" %in% colnames(data)
#> is.double(data[["am"]])
#> !any(is.na(data[["am"]]) | is.null(data[["am"]]))
#> # Duplicate values were detected so this assertion has been disabled:
#> # !any(duplicated(data[["am"]]))
#> min(data[["am"]], na.rm = TRUE) >= 0 # all non-negative
#> # (Un)comment or modify the below range assertions if needed:
#> # max(data[["am"]], na.rm = TRUE) <= 1
#> # 0 <= min(data[["am"]], na.rm = TRUE)
#> # (Un)comment or modify the below deviance assertions if needed.
#> # The mean is 0.41 and the standard deviation is 0.5:
#> # max(data[["am"]], na.rm = TRUE) <= 0.41 + 4 * 0.5
#> # 0.41 - 4 * 0.5 <= max(data[["am"]], na.rm = TRUE)
#>
#> "gear" %in% colnames(data)
#> is.double(data[["gear"]])
#> !any(is.na(data[["gear"]]) | is.null(data[["gear"]]))
#> # Duplicate values were detected so this assertion has been disabled:
#> # !any(duplicated(data[["gear"]]))
#> min(data[["gear"]], na.rm = TRUE) > 0 # all positive
#> # (Un)comment or modify the below range assertions if needed:
#> # max(data[["gear"]], na.rm = TRUE) <= 5
#> # 3 <= min(data[["gear"]], na.rm = TRUE)
#> # (Un)comment or modify the below deviance assertions if needed.
#> # The mean is 3.69 and the standard deviation is 0.74:
#> # max(data[["gear"]], na.rm = TRUE) <= 3.69 + 4 * 0.74
#> # 3.69 - 4 * 0.74 <= max(data[["gear"]], na.rm = TRUE)
#>
#> "carb" %in% colnames(data)
#> is.double(data[["carb"]])
#> !any(is.na(data[["carb"]]) | is.null(data[["carb"]]))
#> # Duplicate values were detected so this assertion has been disabled:
#> # !any(duplicated(data[["carb"]]))
#> min(data[["carb"]], na.rm = TRUE) > 0 # all positive
#> # (Un)comment or modify the below range assertions if needed:
#> # max(data[["carb"]], na.rm = TRUE) <= 8
#> # 1 <= min(data[["carb"]], na.rm = TRUE)
#> # (Un)comment or modify the below deviance assertions if needed.
#> # The mean is 2.81 and the standard deviation is 1.62:
#> # max(data[["carb"]], na.rm = TRUE) <= 2.81 + 4 * 1.62
#> # 2.81 - 4 * 1.62 <= max(data[["carb"]], na.rm = TRUE)
#> })
#> invisible(TRUE)
#> }
exemplar(mtcars, starts_with("d"))
#> validate_mtcars <- function(data) {
#> stopifnot(exprs = {
#> is.data.frame(data)
#> # The data is potentially being subsetted so this assertion has been disabled:
#> # identical(colnames(data), c("disp", "drat"))
#>
#> "disp" %in% colnames(data)
#> is.double(data[["disp"]])
#> !any(is.na(data[["disp"]]) | is.null(data[["disp"]]))
#> # Duplicate values were detected so this assertion has been disabled:
#> # !any(duplicated(data[["disp"]]))
#> min(data[["disp"]], na.rm = TRUE) > 0 # all positive
#> # (Un)comment or modify the below range assertions if needed:
#> # max(data[["disp"]], na.rm = TRUE) <= 472
#> # 71.1 <= min(data[["disp"]], na.rm = TRUE)
#> # (Un)comment or modify the below deviance assertions if needed.
#> # The mean is 230.72 and the standard deviation is 123.94:
#> # max(data[["disp"]], na.rm = TRUE) <= 230.72 + 4 * 123.94
#> # 230.72 - 4 * 123.94 <= max(data[["disp"]], na.rm = TRUE)
#>
#> "drat" %in% colnames(data)
#> is.double(data[["drat"]])
#> !any(is.na(data[["drat"]]) | is.null(data[["drat"]]))
#> # Duplicate values were detected so this assertion has been disabled:
#> # !any(duplicated(data[["drat"]]))
#> min(data[["drat"]], na.rm = TRUE) > 0 # all positive
#> # (Un)comment or modify the below range assertions if needed:
#> # max(data[["drat"]], na.rm = TRUE) <= 4.93
#> # 2.76 <= min(data[["drat"]], na.rm = TRUE)
#> # (Un)comment or modify the below deviance assertions if needed.
#> # The mean is 3.6 and the standard deviation is 0.53:
#> # max(data[["drat"]], na.rm = TRUE) <= 3.6 + 4 * 0.53
#> # 3.6 - 4 * 0.53 <= max(data[["drat"]], na.rm = TRUE)
#> })
#> invisible(TRUE)
#> }
exemplar(mtcars, .function_suffix = "my_data")
#> validate_my_data <- function(data) {
#> stopifnot(exprs = {
#> is.data.frame(data)
#> identical(colnames(data), c("mpg", "cyl", "disp", "hp", "drat", "wt", "qsec", "vs", "am", "gear", "carb"))
#>
#> "mpg" %in% colnames(data)
#> is.double(data[["mpg"]])
#> !any(is.na(data[["mpg"]]) | is.null(data[["mpg"]]))
#> # Duplicate values were detected so this assertion has been disabled:
#> # !any(duplicated(data[["mpg"]]))
#> min(data[["mpg"]], na.rm = TRUE) > 0 # all positive
#> # (Un)comment or modify the below range assertions if needed:
#> # max(data[["mpg"]], na.rm = TRUE) <= 33.9
#> # 10.4 <= min(data[["mpg"]], na.rm = TRUE)
#> # (Un)comment or modify the below deviance assertions if needed.
#> # The mean is 20.09 and the standard deviation is 6.03:
#> # max(data[["mpg"]], na.rm = TRUE) <= 20.09 + 4 * 6.03
#> # 20.09 - 4 * 6.03 <= max(data[["mpg"]], na.rm = TRUE)
#>
#> "cyl" %in% colnames(data)
#> is.double(data[["cyl"]])
#> !any(is.na(data[["cyl"]]) | is.null(data[["cyl"]]))
#> # Duplicate values were detected so this assertion has been disabled:
#> # !any(duplicated(data[["cyl"]]))
#> min(data[["cyl"]], na.rm = TRUE) > 0 # all positive
#> # (Un)comment or modify the below range assertions if needed:
#> # max(data[["cyl"]], na.rm = TRUE) <= 8
#> # 4 <= min(data[["cyl"]], na.rm = TRUE)
#> # (Un)comment or modify the below deviance assertions if needed.
#> # The mean is 6.19 and the standard deviation is 1.79:
#> # max(data[["cyl"]], na.rm = TRUE) <= 6.19 + 4 * 1.79
#> # 6.19 - 4 * 1.79 <= max(data[["cyl"]], na.rm = TRUE)
#>
#> "disp" %in% colnames(data)
#> is.double(data[["disp"]])
#> !any(is.na(data[["disp"]]) | is.null(data[["disp"]]))
#> # Duplicate values were detected so this assertion has been disabled:
#> # !any(duplicated(data[["disp"]]))
#> min(data[["disp"]], na.rm = TRUE) > 0 # all positive
#> # (Un)comment or modify the below range assertions if needed:
#> # max(data[["disp"]], na.rm = TRUE) <= 472
#> # 71.1 <= min(data[["disp"]], na.rm = TRUE)
#> # (Un)comment or modify the below deviance assertions if needed.
#> # The mean is 230.72 and the standard deviation is 123.94:
#> # max(data[["disp"]], na.rm = TRUE) <= 230.72 + 4 * 123.94
#> # 230.72 - 4 * 123.94 <= max(data[["disp"]], na.rm = TRUE)
#>
#> "hp" %in% colnames(data)
#> is.double(data[["hp"]])
#> !any(is.na(data[["hp"]]) | is.null(data[["hp"]]))
#> # Duplicate values were detected so this assertion has been disabled:
#> # !any(duplicated(data[["hp"]]))
#> min(data[["hp"]], na.rm = TRUE) > 0 # all positive
#> # (Un)comment or modify the below range assertions if needed:
#> # max(data[["hp"]], na.rm = TRUE) <= 335
#> # 52 <= min(data[["hp"]], na.rm = TRUE)
#> # (Un)comment or modify the below deviance assertions if needed.
#> # The mean is 146.69 and the standard deviation is 68.56:
#> # max(data[["hp"]], na.rm = TRUE) <= 146.69 + 4 * 68.56
#> # 146.69 - 4 * 68.56 <= max(data[["hp"]], na.rm = TRUE)
#>
#> "drat" %in% colnames(data)
#> is.double(data[["drat"]])
#> !any(is.na(data[["drat"]]) | is.null(data[["drat"]]))
#> # Duplicate values were detected so this assertion has been disabled:
#> # !any(duplicated(data[["drat"]]))
#> min(data[["drat"]], na.rm = TRUE) > 0 # all positive
#> # (Un)comment or modify the below range assertions if needed:
#> # max(data[["drat"]], na.rm = TRUE) <= 4.93
#> # 2.76 <= min(data[["drat"]], na.rm = TRUE)
#> # (Un)comment or modify the below deviance assertions if needed.
#> # The mean is 3.6 and the standard deviation is 0.53:
#> # max(data[["drat"]], na.rm = TRUE) <= 3.6 + 4 * 0.53
#> # 3.6 - 4 * 0.53 <= max(data[["drat"]], na.rm = TRUE)
#>
#> "wt" %in% colnames(data)
#> is.double(data[["wt"]])
#> !any(is.na(data[["wt"]]) | is.null(data[["wt"]]))
#> # Duplicate values were detected so this assertion has been disabled:
#> # !any(duplicated(data[["wt"]]))
#> min(data[["wt"]], na.rm = TRUE) > 0 # all positive
#> # (Un)comment or modify the below range assertions if needed:
#> # max(data[["wt"]], na.rm = TRUE) <= 5.424
#> # 1.513 <= min(data[["wt"]], na.rm = TRUE)
#> # (Un)comment or modify the below deviance assertions if needed.
#> # The mean is 3.22 and the standard deviation is 0.98:
#> # max(data[["wt"]], na.rm = TRUE) <= 3.22 + 4 * 0.98
#> # 3.22 - 4 * 0.98 <= max(data[["wt"]], na.rm = TRUE)
#>
#> "qsec" %in% colnames(data)
#> is.double(data[["qsec"]])
#> !any(is.na(data[["qsec"]]) | is.null(data[["qsec"]]))
#> # Duplicate values were detected so this assertion has been disabled:
#> # !any(duplicated(data[["qsec"]]))
#> min(data[["qsec"]], na.rm = TRUE) > 0 # all positive
#> # (Un)comment or modify the below range assertions if needed:
#> # max(data[["qsec"]], na.rm = TRUE) <= 22.9
#> # 14.5 <= min(data[["qsec"]], na.rm = TRUE)
#> # (Un)comment or modify the below deviance assertions if needed.
#> # The mean is 17.85 and the standard deviation is 1.79:
#> # max(data[["qsec"]], na.rm = TRUE) <= 17.85 + 4 * 1.79
#> # 17.85 - 4 * 1.79 <= max(data[["qsec"]], na.rm = TRUE)
#>
#> "vs" %in% colnames(data)
#> is.double(data[["vs"]])
#> !any(is.na(data[["vs"]]) | is.null(data[["vs"]]))
#> # Duplicate values were detected so this assertion has been disabled:
#> # !any(duplicated(data[["vs"]]))
#> min(data[["vs"]], na.rm = TRUE) >= 0 # all non-negative
#> # (Un)comment or modify the below range assertions if needed:
#> # max(data[["vs"]], na.rm = TRUE) <= 1
#> # 0 <= min(data[["vs"]], na.rm = TRUE)
#> # (Un)comment or modify the below deviance assertions if needed.
#> # The mean is 0.44 and the standard deviation is 0.5:
#> # max(data[["vs"]], na.rm = TRUE) <= 0.44 + 4 * 0.5
#> # 0.44 - 4 * 0.5 <= max(data[["vs"]], na.rm = TRUE)
#>
#> "am" %in% colnames(data)
#> is.double(data[["am"]])
#> !any(is.na(data[["am"]]) | is.null(data[["am"]]))
#> # Duplicate values were detected so this assertion has been disabled:
#> # !any(duplicated(data[["am"]]))
#> min(data[["am"]], na.rm = TRUE) >= 0 # all non-negative
#> # (Un)comment or modify the below range assertions if needed:
#> # max(data[["am"]], na.rm = TRUE) <= 1
#> # 0 <= min(data[["am"]], na.rm = TRUE)
#> # (Un)comment or modify the below deviance assertions if needed.
#> # The mean is 0.41 and the standard deviation is 0.5:
#> # max(data[["am"]], na.rm = TRUE) <= 0.41 + 4 * 0.5
#> # 0.41 - 4 * 0.5 <= max(data[["am"]], na.rm = TRUE)
#>
#> "gear" %in% colnames(data)
#> is.double(data[["gear"]])
#> !any(is.na(data[["gear"]]) | is.null(data[["gear"]]))
#> # Duplicate values were detected so this assertion has been disabled:
#> # !any(duplicated(data[["gear"]]))
#> min(data[["gear"]], na.rm = TRUE) > 0 # all positive
#> # (Un)comment or modify the below range assertions if needed:
#> # max(data[["gear"]], na.rm = TRUE) <= 5
#> # 3 <= min(data[["gear"]], na.rm = TRUE)
#> # (Un)comment or modify the below deviance assertions if needed.
#> # The mean is 3.69 and the standard deviation is 0.74:
#> # max(data[["gear"]], na.rm = TRUE) <= 3.69 + 4 * 0.74
#> # 3.69 - 4 * 0.74 <= max(data[["gear"]], na.rm = TRUE)
#>
#> "carb" %in% colnames(data)
#> is.double(data[["carb"]])
#> !any(is.na(data[["carb"]]) | is.null(data[["carb"]]))
#> # Duplicate values were detected so this assertion has been disabled:
#> # !any(duplicated(data[["carb"]]))
#> min(data[["carb"]], na.rm = TRUE) > 0 # all positive
#> # (Un)comment or modify the below range assertions if needed:
#> # max(data[["carb"]], na.rm = TRUE) <= 8
#> # 1 <= min(data[["carb"]], na.rm = TRUE)
#> # (Un)comment or modify the below deviance assertions if needed.
#> # The mean is 2.81 and the standard deviation is 1.62:
#> # max(data[["carb"]], na.rm = TRUE) <= 2.81 + 4 * 1.62
#> # 2.81 - 4 * 1.62 <= max(data[["carb"]], na.rm = TRUE)
#> })
#> invisible(TRUE)
#> }