# NOT RUN {
data(testData)
data(toyData)
check(toyData)
# }
# NOT RUN {
DF <- data.frame(x = 1:15)
clean(DF)
# }
# NOT RUN {
# }
# NOT RUN {
data(testData)
clean(testData)
# }
# NOT RUN {
# Overwrite any existing files generated by clean
# }
# NOT RUN {
clean(testData, replace=TRUE)
# }
# NOT RUN {
# Only include problematic variables in the output document
# }
# NOT RUN {
clean(testData, replace=TRUE, onlyProblematic=TRUE)
# }
# NOT RUN {
# Add user defined check-function to the checks performed on character variables:
# Here we add functionality to search for the string wally (ignoring case)
# }
# NOT RUN {
wheresWally <- function(v, ...) {
res <- grepl("wally", v, ignore.case=TRUE)
problem <- any(res)
message <- "Wally was found in these data"
checkResult(list(problem = problem,
message = message,
problemValues = v[res]))
}
wheresWally <- checkFunction(wheresWally,
description = "Search for the string 'wally' ignoring case",
classes = c("character")
)
# Add the newly defined function to the list of checks used for characters.
clean(testData, characterChecks=c(defaultCharacterChecks(), "wheresWally"),
replace=TRUE)
# }
# NOT RUN {
#Handle non-supported variable classes using treatXasY: treat raw as character and
#treat complex as numeric. We also add a list variable, but as lists are not
#handled through treatXasY, this variable will be caught in the preChecks and skipped:
# }
# NOT RUN {
toyData$rawVar <- as.raw(c(1:14, 1))
toyData$compVar <- c(1:14, 1) + 2i
toyData$listVar <- as.list(c(1:14, 1))
clean(toyData, replace = TRUE, treatXasY = list(raw = "character", complex = "numeric"))
# }
# NOT RUN {
# }
Run the code above in your browser using DataLab