Description Usage Arguments Author(s) See Also Examples
Tests a Standard R 'data.frame' by shape, rownames and colnames ('RTestTest_data.frame_shape')
1 2 | test_returnValue_data.frame_shape(result, reference, xmlTestSpec,
add.desc = NULL)
|
result |
( |
reference |
( |
xmlTestSpec |
( |
add.desc |
( |
Sebastian Wolf sebastian.wolf.sw1@roche.com
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 | # Cleaning up
tryCatch(unloadNamespace("RTest"))
tryCatch(unloadNamespace("testthat"))
library(RTest)
# create some definition of tests
data <- '<test_df desc="Compare a value" diff-type="relative"
compare-type="equal" tolerance="1E-6"/>'
xmlTestSpec <- XML::xmlRoot(XML::xmlParse(data,asText=TRUE))
# Create data frames
x <- data.frame(x=c(1,2,3,4),y=c(1,2,3,4))
y <- data.frame(x=c(1,2,3,4),y=c(1,2,3,4))
y_wrong_shape <- data.frame(x=c(1,2,3,4,5),y=c(1,2,3,4,5))
y_wrong_names <- data.frame(x=c(1,2,3,4),y1=c(1,2,3,4))
test_returnValue_data.frame_shape(x,y,xmlTestSpec)
# Test for shape
tryCatch(
{test_returnValue_data.frame_shape(x,y_wrong_shape,xmlTestSpec)
stop("test did not find difference")},
error=function(e){
stopifnot(grepl("rec.nrows",e))
stopifnot(grepl("exp.nrows",e))
stopifnot(grepl("not equal",e))
})
# Test for column names
data <- '<test_df check_colnames="TRUE"
desc="Compare a value" diff-type="relative"
compare-type="equal" tolerance="1E-6"/>'
xmlTestSpec <- XML::xmlRoot(XML::xmlParse(data,asText=TRUE))
tryCatch({
test_returnValue_data.frame_shape(x,y_wrong_names,xmlTestSpec)
stop("test did not find difference")},
error=function(e){
stopifnot(grepl("rec.name",e))
stopifnot(grepl("exp.name",e))
stopifnot(grepl("not equal",e))
})
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.