Description Arguments Value Methods Examples
Methods which check one object against another object
containing constraints which must be met. Most commonly a
data.frame
is checked against constraints in a
TableChecks
object.
object |
The object to be checked. |
checks |
The object containing the constraints. |
TRUE
if all constraints are met. If a constraint
is failed, a character
vector describing the
problems.
signature(object = "ANY", checks =
"ColumnChecks")
signature(object =
"data.frame", checks = "TableChecks")
signature(object = "CheckedFrame", checks =
"missing")
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 | # create a TableChecks object
# Require a numeric column foo and a factor column bar#
# Also require foo to be positive
positive <- function(x) x > 0
columns <- ColumnCheckList(foo = ColumnChecks(classtype = "numeric",
constraints = FunctionList(postive=positive)),
bar = ColumnChecks(classtype = "factor"))
# Require that the data.frame can contain ONLY foo and bar
checks <- TableChecks(columns = columns, exclusive = TRUE)
# this data frame is valid
check_constraints(data.frame(foo = 1:26, bar = letters),
checks)
# these are invalid
check_constraints(data.frame(foo = -(1:26), bar=letters), checks)
check_constraints(data.frame(foo = 1:26, bar=1:26), checks)
check_constraints(data.frame(foo = 1:26, bar=letters, baz=letters),
checks)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.