confront | R Documentation |
An expressionset is a general class storing rich expressions (basically
expressions and some meta data) which we call 'rules'. Examples of
expressionset implementations are validator
objects, storing
validation rules and indicator
objects, storing data quality
indicators. The confront
function evaluates the expressions one by one
on a dataset while recording some process meta data. All results are stored in
a (subclass of a) confrontation
object.
confront(dat, x, ref, ...)
## S4 method for signature 'data.frame,indicator,ANY'
confront(dat, x, key = NULL, ...)
## S4 method for signature 'data.frame,indicator,environment'
confront(dat, x, ref, key = NULL, ...)
## S4 method for signature 'data.frame,indicator,data.frame'
confront(dat, x, ref, key = NULL, ...)
## S4 method for signature 'data.frame,indicator,list'
confront(dat, x, ref, key = NULL, ...)
## S4 method for signature 'data.frame,validator,ANY'
confront(dat, x, key = NULL, ...)
## S4 method for signature 'data.frame,validator,environment'
confront(dat, x, ref, key = NULL, ...)
## S4 method for signature 'data.frame,validator,data.frame'
confront(dat, x, ref, key = NULL, ...)
## S4 method for signature 'data.frame,validator,list'
confront(dat, x, ref, key = NULL, ...)
dat |
An R object carrying data |
x |
An R object carrying |
ref |
Optionally, an R object carrying reference data. See examples for usage. |
... |
Options used at execution time (especially |
key |
(optional) name of identifying variable in x. |
Reference data is typically a list
with a items such as
a code list, or a data frame of which rows match the rows of the
data under scrutiny.
voptions
Other confrontation-methods:
[,expressionset-method
,
as.data.frame,confrontation-method
,
confrontation-class
,
errors()
,
event()
,
keyset()
,
length,expressionset-method
,
values()
Other validation-methods:
aggregate,validation-method
,
all,validation-method
,
any,validation-method
,
barplot,validation-method
,
check_that()
,
compare()
,
event()
,
names<-,rule,character-method
,
plot,validation-method
,
sort,validation-method
,
summary()
,
validation-class
,
values()
Other indication-methods:
event()
,
indication-class
,
summary()
# a basic validation example
v <- validator(height/weight < 0.5, mean(height) >= 0)
cf <- confront(women, v)
summary(cf)
plot(cf)
as.data.frame(cf)
# an example checking metadata
v <- validator(nrow(.) == 15, ncol(.) > 2)
summary(confront(women, v))
# An example using reference data
v <- validator(weight == ref$weight)
summary(confront(women, v, women))
# Usging custom names for reference data
v <- validator(weight == test$weight)
summary( confront(women,v, list(test=women)) )
# Reference data in an environment
e <- new.env()
e$test <- women
v <- validator(weight == test$weight)
summary( confront(women, v, e) )
# the effect of using a key
w <- women
w$id <- letters[1:nrow(w)]
v <- validator(weight == ref$weight)
# with complete data; already matching
values( confront(w, v, w, key='id'))
# with scrambled rows in reference data (reference gets sorted according to dat)
i <- sample(nrow(w))
values(confront(w, v, w[i,],key='id'))
# with incomplete reference data
values(confront(w, v, w[1:10,],key='id'))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.