Description Usage Arguments Details Value Author(s) Examples
write_rule
is a function to help you write new rules. Can write several rules at once using vectors.
1 | write_rule(name, x, type, y, def , result, na.rm = "", multiple)
|
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:
|
y |
vector. Used in |
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 |
na.rm |
logical or empty (""). Should the |
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) |
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:
summary
Both x
and y
are expected to be a data.frame/table object either with columns 'id' and 'value', or with two columns only (in this case, first column is expected to be id and second to contain value).
def
The defined function must have a name (you cannot use operators such as <
). If you want to use two parameters (not only x
) in the function (such as rewriting operator as named function function(a,b){a < b}
), then you need to specify the other parameter as y
. If you want to compare a result of a function with some predefined value (suck as mean(x) == number
), you need to specify the parameter result
as this number
. If the function output is vector with lenght > 1, it is expected to contain logical values and will be summarized (not compared with parameter result
) for the final output..
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 ==
.)
Returns a message confirming the creation of new rule.
Michal Kubista
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)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.