write_rule: Write new rule to be verified.

Description Usage Arguments Details Value Author(s) Examples

Description

write_rule is a function to help you write new rules. Can write several rules at once using vectors.

Usage

1
write_rule(name, x, type, y, def , result, na.rm = "", multiple)

Arguments

name

character. Name of the rule. Needs to be unique for every rule.

x

object. Data against which the rule is to be verified.

type

character. Possible types are:

  • integ checks for presence of all unique values of x in y

  • summary checks summarised data against original, more detailed data

  • na checks the missing values

  • def any other type, needs to be defined in def parametr.

y

vector. Used in type integrity (y is the reference table), summary (y is the summarised table), or in some cases of def.

def

character. Used for user defined rules using any function in environment, accepts only the name of the function, e.g. "sum".

result

numeric. Used for type numeric, def, or summary to specify bounds, expected value or accuracy for summary, check Details for more explanation.

na.rm

logical or empty (""). Should the NA values be ommitted in computations of summaries and user defined functions? Empty, if the function does not use na.rm argument (or it should use default value).

multiple

logical. Are multiple rules being written? If TRUE, then x (and y, if used) should be the names of the objects (not the objects themself)

Details

You can create several rules at once assigning vectors into the parametrs and specifying multiple = TRUE. When the length of any parameter is longer than one the function uses cbind to create a data.frame (will repeat values of vectors with smaller size). Names of the rules need to be unique.
Special requirements:

There is a special use of parameter result in case of type = summary, in this case result can be used to define accuracy (tolerance of difference between values). Default tolerance is 0 (compared using ==.)

Value

Returns a message confirming the creation of new rule.

Author(s)

Michal Kubista

Examples

1
2
3
4
5
6
7
8
9
## Not run: 
write_rule(name = "test1", x = mtcars$mpg, type = "def", def = "mean",
           result = 19.2, na.rm = TRUE)
# verify, that the mean  of mtcars$mpg is 19.2, omitting the missing values

write_rule(name = "integrity1", x = data$cities, type = "integ", y = "ref$cities")
# verify, that all of the cities used in the data are present in the reference table

## End(Not run)

kubistmi/verifier documentation built on May 14, 2019, 7:42 a.m.