#library(knitr) options(htmltools.dir.version = FALSE, cache=TRUE) #opts_chunk$set(dev.args=list(bg="transparent"), fig.width=15, fig.height=7) source("kutheme.R") library(dataMaid) library(assertr) library(dplyr) library(validate) data(bigPresidentData) bpD <- bigPresidentData
knitr::include_graphics("pics/colrow1.png")
knitr::include_graphics("pics/colrow2.png")
knitr::include_graphics("pics/colrow3.png")
dataMaid performs class dependent checks for each variable in a dataset, one at a time (column-wise)An R-packages that performs row-wise checks: validate
library(validate)
Note: Different use of the term "validation" - no longer about format, type and range, but used as synonym to "check".
validate - overview:validator object, using the valdiator() function.confront, thereby obtaining a confrontation object.validator object). validator object.footnotesize[
val1 <- validator( ageAtDeath := floor((dateOfDeath - birthday)/365.25), `Adult president` = ageAtInauguration >= 18, `Alive at inauguration` = ageAtDeath >= ageAtInauguration, `Positive first name` = firstName*2 > firstName, `Death by assassination` = if (dateOfDeath == presidencyEndDate) assassinationAttempt == 1 )
]
validator object:.footnotesize[
con1 <- confront(bpD, val1) summary(con1)[, 1:6]
]
Lots of functions available for inspecting confrontations:
summary(): Overview of confrontation results
aggregate(): Compute percentage pass/fail/na
sort(): Sort results by problem prevalence
values(): For each observation and each check: TRUE/FALSE/NA
barplot(): Visual overview of check results
errors(): What errors were caught?
* warnings(): What warnings were caught?
validator and confrontation objects imply use of "modify-by-reference" rather than "copy-on-modify" semantics (standard R)data.tablev1 <- validator(check1 = sex == "Male") v1 v2 <- v1 names(v2) <- "All males" v1
Make a copy using [TRUE]:
v1 <- validator(check1 = sex == "Male") v2 <- v1[TRUE] names(v2) <- "All males" v1
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.