check_values: Utility functions for wrappers. Name and value checking, for...

Description Usage Arguments Details Examples

View source: R/Utils_Methods.R

Description

A generic checking utility. This will need various presets of values for the various possible columns, and may have its own wrappers for each.

Usage

1
check_values(x, expected.values, categorical = FALSE)

Arguments

x

vector of values, factor,character,numeric,integer, etc.

expected.values

set of valid values if categorical == TRUE, otherwise the valid value range.

categorical

logical. Does the value represent categories? Default FALSE for magnitudes or similar.

Details

make sure values in a column are as expected

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
expected.values <- c(0,1)
# can be a check on probabilities, perhaps they're in logit and we dont' realize it?
x <- runif(10)
x <- log(x/(1-x))
#out <- try(check_values(x,c(0,1),categorical = FALSE))
# de facto unit test..
#stopifnot(class(out) == "try-error")

# factors are checked against characters here.
y <- as.factor(c("a","b","c"))
check_values(y,letters,categorical = TRUE)

timriffe/DDSQLtools documentation built on Oct. 6, 2021, 5:34 p.m.