A concise overview of the validate syntax.
Metadata such as numer of rows, columns, column names and so on can be
tested by referencing the whole data set with the '.'. For example,
the rule nrow(.) == 15 checks whether there are 15 rows in the
dataset at hand.
The operator `:=' can be used to set up local variables (during, for example, validation) to save
time (the rhs of an assignment is computed only once) or to make your validation code more maintainable.
Assignments work more or less like common R assignments: they are only valid for statements coming after
the assignment and they may be overwritten. The result of computing the rhs is not part of a
confrontation with data.
Often the same constraints/rules are valid for groups of variables.
validate allows for compact notation. Variable groups can be used in-statement
or by defining them with the := operator.
validator( var_group(a,b) > 0 )
is equivalent to
validator(G := var_group(a,b), G > 0)
is equivalent to
validator(a>0,b>0).
Using two groups results in the cartesian product of checks. So the statement
validator( f=var_group(c,d), g=var_group(a,b), g > f)
is equivalent to
validator(a > c, b > c, a > d, b > d)
Please see the vignette on how to read rules from and write rules to file:
vignette("rule-files",package="validate")