library(testthat) # most common expectations: # equality: expect_equal() and expect_identical() # regexp: expect_match() # catch-all: expect_true() and expect_false() # console output: expect_output() # messages: expect_message() # warning: expect_warning() # errors: expect_error() escapeString <- function(s) { t <- gsub("(\\\\)", "\\\\\\\\", s) t <- gsub("(\n)", "\\\\n", t) t <- gsub("(\r)", "\\\\r", t) t <- gsub("(\")", "\\\\\"", t) return(t) } prepStr <- function(s) { t <- escapeString(s) u <- eval(parse(text=paste0("\"", t, "\""))) if(s!=u) stop("Unable to escape string!") t <- paste0("\thtml <- \"", t, "\"") utils::writeClipboard(t) return(invisible()) } evaluationMode <- "sequential" processingLibrary <- "dplyr" description <- "test: sequential dplyr" countFunction <- "n()" isDevelopmentVersion <- (length(strsplit(packageDescription("pivottabler")$Version, "\\.")[[1]]) > 3) testScenarios <- function(description="test", releaseEvaluationMode="batch", releaseProcessingLibrary="dplyr", runAllForReleaseVersion=FALSE) { isDevelopmentVersion <- (length(strsplit(packageDescription("pivottabler")$Version, "\\.")[[1]]) > 3) if(isDevelopmentVersion||runAllForReleaseVersion) { evaluationModes <- c("sequential", "batch") processingLibraries <- c("dplyr", "data.table") } else { evaluationModes <- releaseEvaluationMode processingLibraries <- releaseProcessingLibrary } testCount <- length(evaluationModes)*length(processingLibraries) c1 <- character(testCount) c2 <- character(testCount) c3 <- character(testCount) c4 <- character(testCount) testCount <- 0 for(evaluationMode in evaluationModes) for(processingLibrary in processingLibraries) { testCount <- testCount + 1 c1[testCount] <- evaluationMode c2[testCount] <- processingLibrary c3[testCount] <- paste0(description, ": ", evaluationMode, " ", processingLibrary) c4[testCount] <- ifelse(processingLibrary=="data.table", ".N", "n()") } df <- data.frame(evaluationMode=c1, processingLibrary=c2, description=c3, countFunction=c4, stringsAsFactors=FALSE) return(df) } context("IRREGULAR LAYOUT TESTS") scenarios <- testScenarios("irregular layout tests: simple example") for(i in 1:nrow(scenarios)) { evaluationMode <- scenarios$evaluationMode[i] processingLibrary <- scenarios$processingLibrary[i] description <- scenarios$description[i] countFunction <- scenarios$countFunction[i] test_that(description, { skip_on_cran() library(pivottabler) pt <- PivotTable$new(processingLibrary=processingLibrary, evaluationMode=evaluationMode, compatibility=list(totalStyleIsCellStyle=TRUE, explicitHeaderSpansOfOne=TRUE)) pt$addData(bhmtrains) pt$columnGroup$addChildGroup(variableName="TrainCategory", values="Express Passenger") pt$columnGroup$addChildGroup(variableName="PowerType", values="DMU") pt$addRowDataGroups("TOC") pt$defineCalculation(calculationName="TotalTrains", summariseExpression=countFunction) pt$evaluatePivot() # pt$renderPivot() # sum(pt$cells$asMatrix(), na.rm=TRUE) # prepStr(as.character(pt$getHtml())) html <- "\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
 Express PassengerDMU
Arriva Trains Wales30793909
CrossCountry2286522196
London Midland1448711229
Virgin Trains85942137
Total4902539471
" expect_equal(sum(pt$cells$asMatrix(), na.rm=TRUE), 176992) expect_identical(as.character(pt$getHtml()), html) }) } scenarios <- testScenarios("irregular layout tests: two-level example A") for(i in 1:nrow(scenarios)) { if(!isDevelopmentVersion) break evaluationMode <- scenarios$evaluationMode[i] processingLibrary <- scenarios$processingLibrary[i] description <- scenarios$description[i] countFunction <- scenarios$countFunction[i] test_that(description, { library(pivottabler) pt <- PivotTable$new(processingLibrary=processingLibrary, evaluationMode=evaluationMode, compatibility=list(totalStyleIsCellStyle=TRUE, explicitHeaderSpansOfOne=TRUE)) pt$addData(bhmtrains) cg1 <- pt$columnGroup$addChildGroup(variableName="TrainCategory", values="Express Passenger") cg2 <- pt$columnGroup$addChildGroup(variableName="PowerType", values="DMU") cg1$addChildGroup(variableName="Status", values="A") cg1$addChildGroup(variableName="Status", values="R") cg2$addChildGroup(variableName="SchedSpeedMPH", values="100") pt$addRowDataGroups("TOC") pt$defineCalculation(calculationName="TotalTrains", summariseExpression=countFunction) pt$evaluatePivot() # pt$renderPivot() # sum(pt$cells$asMatrix(), na.rm=TRUE) # prepStr(as.character(pt$getHtml())) html <- "\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
 Express PassengerDMU
AR100
Arriva Trains Wales30182
CrossCountry222702611024
London Midland14133182723
Virgin Trains83599
Total477805513747
" expect_equal(sum(pt$cells$asMatrix(), na.rm=TRUE), 123164) expect_identical(as.character(pt$getHtml()), html) }) } scenarios <- testScenarios("irregular layout tests: two-level example B") for(i in 1:nrow(scenarios)) { if(!isDevelopmentVersion) break evaluationMode <- scenarios$evaluationMode[i] processingLibrary <- scenarios$processingLibrary[i] description <- scenarios$description[i] countFunction <- scenarios$countFunction[i] test_that(description, { library(pivottabler) pt <- PivotTable$new(processingLibrary=processingLibrary, evaluationMode=evaluationMode, compatibility=list(totalStyleIsCellStyle=TRUE, explicitHeaderSpansOfOne=TRUE, noDataGroupNBSP=TRUE)) pt$addData(bhmtrains) cg1 <- pt$columnGroup$addChildGroup(variableName="TrainCategory", values="Express Passenger") cg2 <- pt$columnGroup$addChildGroup(variableName="PowerType", values="DMU") cg1$addDataGroups("Status") cg2$addDataGroups("SchedSpeedMPH") pt$addRowDataGroups("TOC") pt$defineCalculation(calculationName="TotalTrains", summariseExpression=countFunction) pt$evaluatePivot() # pt$renderPivot() # sum(pt$cells$asMatrix(), na.rm=TRUE) # prepStr(as.character(pt$getHtml())) html <- "\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
 Express PassengerDMU
ACRTotal7590100125NATotal
Arriva Trains Wales301859230791213761273909
CrossCountry222705692622865110241104013222196
London Midland141333361814487610423992723311229
Virgin Trains835922698594213522137
Total477801190554902562256160137471317516439471
" expect_equal(sum(pt$cells$asMatrix(), na.rm=TRUE), 353984) expect_identical(as.character(pt$getHtml()), html) }) } scenarios <- testScenarios("irregular layout tests: two-level example C") for(i in 1:nrow(scenarios)) { if(!isDevelopmentVersion) break evaluationMode <- scenarios$evaluationMode[i] processingLibrary <- scenarios$processingLibrary[i] description <- scenarios$description[i] countFunction <- scenarios$countFunction[i] test_that(description, { library(pivottabler) pt <- PivotTable$new(processingLibrary=processingLibrary, evaluationMode=evaluationMode, compatibility=list(totalStyleIsCellStyle=TRUE, explicitHeaderSpansOfOne=TRUE, noDataGroupNBSP=TRUE)) pt$addData(bhmtrains) pt$addColumnDataGroups("TrainCategory") cgrps <- pt$addColumnDataGroups("PowerType") add2Groups <- function(grp) { if(!grp$isTotal) { grp$addChildGroup(variableName="Status", values="A") grp$addChildGroup(variableName="Status", values="R") } } invisible(lapply(cgrps, add2Groups)) pt$addRowDataGroups("TOC") pt$defineCalculation(calculationName="TotalTrains", summariseExpression=countFunction) pt$evaluatePivot() # pt$renderPivot() # sum(pt$cells$asMatrix(), na.rm=TRUE) # prepStr(as.character(pt$getHtml())) html <- "\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
 Express PassengerOrdinary PassengerTotal
DMUEMUHSTTotalDMUEMUTotal
ARARARARAR
Arriva Trains Wales3018230798158303909
CrossCountry2156126709228656016322928
London Midland55343859915144875520427331233379248279
Virgin Trains202826331785948594
Total32141331493022709490256395527331233468583710
" expect_equal(sum(pt$cells$asMatrix(), na.rm=TRUE), 498018) expect_identical(as.character(pt$getHtml()), html) }) } scenarios <- testScenarios("irregular layout tests: empty groups") for(i in 1:nrow(scenarios)) { if(!isDevelopmentVersion) break evaluationMode <- scenarios$evaluationMode[i] processingLibrary <- scenarios$processingLibrary[i] description <- scenarios$description[i] countFunction <- scenarios$countFunction[i] test_that(description, { library(pivottabler) pt <- PivotTable$new(processingLibrary=processingLibrary, evaluationMode=evaluationMode, compatibility=list(totalStyleIsCellStyle=TRUE, explicitHeaderSpansOfOne=TRUE)) pt$addData(bhmtrains) cg1 <- pt$columnGroup$addChildGroup(variableName="TrainCategory", values="Express Passenger") cg2 <- pt$columnGroup$addChildGroup(variableName="PowerType", values="DMU") pt$addRowDataGroups("TOC") pt$defineCalculation(calculationName="TotalTrains", summariseExpression=countFunction) pt$defineCalculation(calculationGroupName="calcGrp2", calculationName="MaxSpeedMPH", summariseExpression="max(SchedSpeedMPH, na.rm=TRUE)") cg3 <- cg1$addChildGroup(caption="Count") cg4 <- cg2$addChildGroup(caption="Maximum Speed") cg3$addCalculationGroups("default") cg4$addCalculationGroups("calcGrp2") pt$evaluatePivot() # pt$renderPivot() # sum(pt$cells$asMatrix(), na.rm=TRUE) # prepStr(as.character(pt$getHtml())) html <- "\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
 Express PassengerDMU
CountMaximum Speed
Arriva Trains Wales307990
CrossCountry22865125
London Midland14487100
Virgin Trains8594125
Total49025125
" expect_equal(sum(pt$cells$asMatrix(), na.rm=TRUE), 98615) expect_identical(as.character(pt$getHtml()), html) }) } scenarios <- testScenarios("irregular layout tests: adding and removing individual groups") for(i in 1:nrow(scenarios)) { if(!isDevelopmentVersion) break evaluationMode <- scenarios$evaluationMode[i] processingLibrary <- scenarios$processingLibrary[i] description <- scenarios$description[i] countFunction <- scenarios$countFunction[i] test_that(description, { library(pivottabler) pt <- PivotTable$new(processingLibrary=processingLibrary, evaluationMode=evaluationMode) pt$addData(bhmtrains) pt$addColumnDataGroups("TrainCategory") grps <- pt$addRowDataGroups("TOC") pt$defineCalculation(calculationName="TotalTrains", summariseExpression=countFunction) pt$rowGroup$addChildGroup(caption="Test 1a", insertAtIndex=3, isEmpty=TRUE) pt$rowGroup$addChildGroup(caption="Test 1b", insertAtIndex=4, isEmpty=TRUE, mergeEmptySpace="doNotMerge") pt$rowGroup$addChildGroup(caption="Test 1c", insertAtIndex=5) pt$rowGroup$addChildGroup(caption="Test 2", insertBefore=grps[[3]]) pt$rowGroup$addChildGroup(caption="Test 3", insertAfter=grps[[3]]) grp <- pt$rowGroup$addChildGroup(caption="Test 4", insertAfter=grps[[4]]) grp$removeGroup() pt$evaluatePivot() # pt$renderPivot() # sum(pt$cells$asMatrix(), na.rm=TRUE) # prepStr(as.character(pt$getHtml())) html <- "\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
 Express PassengerOrdinary PassengerTotal
Arriva Trains Wales30798303909
CrossCountry228656322928
Test 1a 
Test 1b
Test 1c490253468583710
Test 2490253468583710
London Midland144873379248279
Test 3490253468583710
Virgin Trains85948594
Total490253468583710
" expect_equal(sum(pt$cells$asMatrix(), na.rm=TRUE), 837100) expect_identical(as.character(pt$getHtml()), html) }) } scenarios <- testScenarios("irregular layout tests: combine pivot 1") for(i in 1:nrow(scenarios)) { evaluationMode <- scenarios$evaluationMode[i] processingLibrary <- scenarios$processingLibrary[i] description <- scenarios$description[i] countFunction <- scenarios$countFunction[i] test_that(description, { skip_on_cran() library(pivottabler) pt <- PivotTable$new(processingLibrary=processingLibrary, evaluationMode=evaluationMode, compatibility=list(noDataGroupNBSP=TRUE)) pt$addData(bhmtrains) pt$addColumnDataGroups("TrainCategory") # Rows: TOC breakdown grp1 <- pt$addRowGroup(caption="By TOC") grp1$addDataGroups("TOC", addTotal=FALSE) # Rows: Power Type breakdown grp2 <- pt$addRowGroup(caption="By Power Type") grp2$addDataGroups("PowerType", addTotal=FALSE) # Rows: Total grp3 <- pt$addRowGroup(caption="Total") # Row Group Headings pt$setRowDataGroupHeader(levelNumber=1, header="Breakdown") pt$setRowDataGroupHeader(levelNumber=2, header="Subset") # Finish... pt$defineCalculation(calculationName="TotalTrains", summariseExpression=countFunction) pt$theme <- getStandardTableTheme(pt) pt$evaluatePivot() # pt$renderPivot(showRowGroupHeaders=TRUE) # sum(pt$cells$asMatrix(), na.rm=TRUE) # prepStr(as.character(pt$getHtml(showRowGroupHeaders=TRUE))) html <- "\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
BreakdownSubsetExpress PassengerOrdinary PassengerTotal
By TOCArriva Trains Wales30798303909
CrossCountry228656322928
London Midland144873379248279
Virgin Trains85948594
By Power TypeDMU32987648439471
EMU153062820143507
HST732732
Total490253468583710
" expect_equal(sum(pt$cells$asMatrix(), na.rm=TRUE), 502260) expect_identical(as.character(pt$getHtml(showRowGroupHeaders=TRUE)), html) }) } scenarios <- testScenarios("irregular layout tests: combine pivot 2") for(i in 1:nrow(scenarios)) { if(!isDevelopmentVersion) break evaluationMode <- scenarios$evaluationMode[i] processingLibrary <- scenarios$processingLibrary[i] description <- scenarios$description[i] countFunction <- scenarios$countFunction[i] test_that(description, { library(pivottabler) pt <- PivotTable$new(processingLibrary=processingLibrary, evaluationMode=evaluationMode, compatibility=list(noDataGroupNBSP=TRUE)) pt$addData(bhmtrains) pt$addColumnDataGroups("TrainCategory") # Rows: TOC breakdown grp1a <- pt$addRowGroup(caption="By TOC", isOutline=TRUE, isEmpty=TRUE, sortAnchor="next", styleDeclarations=list(color="blue")) grp1b <- pt$addRowGroup() grp1b$addDataGroups("TOC", addTotal=FALSE) # Rows: Power Type breakdown grp2a <- pt$addRowGroup(caption="By Power Type", isOutline=TRUE, isEmpty=TRUE, sortAnchor="next", styleDeclarations=list(color="blue")) grp2b <- pt$addRowGroup() grp2b$addDataGroups("PowerType", addTotal=FALSE) # Rows: Total grp3 <- pt$addRowGroup(caption="Total", isOutline=TRUE, styleDeclarations=list(color="blue")) # Finish... pt$defineCalculation(calculationName="TotalTrains", summariseExpression=countFunction) pt$evaluatePivot() # pt$renderPivot() # sum(pt$cells$asMatrix(), na.rm=TRUE) # prepStr(as.character(pt$getHtml())) html <- "\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
 Express PassengerOrdinary PassengerTotal
By TOC 
Arriva Trains Wales30798303909
CrossCountry228656322928
London Midland144873379248279
Virgin Trains85948594
By Power Type 
DMU32987648439471
EMU153062820143507
HST732732
Total490253468583710
" expect_equal(sum(pt$cells$asMatrix(), na.rm=TRUE), 502260) expect_identical(as.character(pt$getHtml()), html) }) } scenarios <- testScenarios("irregular layout tests: combine pivot 3") for(i in 1:nrow(scenarios)) { if(!isDevelopmentVersion) break evaluationMode <- scenarios$evaluationMode[i] processingLibrary <- scenarios$processingLibrary[i] description <- scenarios$description[i] countFunction <- scenarios$countFunction[i] test_that(description, { gender <- c("F", "F", "F", "F", "F", "F", "F", "F", "F", "F", "F", "F", "F", "F", "F", "F", "F", "F", "F", "F", "M", "M", "M", "M", "M", "M", "M", "M", "M", "M", "M", "M", "M", "M", "M", "M", "M", "M", "M", "M") age <- c(19, 19, 19, 19, 19, 20, 20, 20, 20, 20, 21, 21, 21, 21, 21, 22, 22, 22, 22, 22, 19, 19, 19, 19, 19, 20, 20, 20, 20, 20, 21, 21, 21, 21, 21, 22, 22, 22, 22, 22) grade <- c("A", "B", "C", "D", "E", "A", "B", "C", "D", "E", "A", "B", "C", "D", "E", "A", "B", "C", "D", "E", "A", "B", "C", "D", "E", "A", "B", "C", "D", "E", "A", "B", "C", "D", "E", "A", "B", "C", "D", "E") counts <- c(6, 16, 56, 37, 213, 14, 21, 61, 45, 191, 30, 54, 74, 82, 246, 91, 46, 29, 71, 296, 3, 6, 21, 35, 162, 14, 11, 29, 22, 204, 15, 30, 49, 75, 253, 45, 22, 30, 30, 319) df <- data.frame(gender, age, grade, counts) library(pivottabler) pt <- PivotTable$new(processingLibrary=processingLibrary, evaluationMode=evaluationMode) pt$addData(df) pt$addColumnDataGroups("grade") pt$addRowGroup(caption="Age", isEmpty=TRUE, isOutline=TRUE, styleDeclarations=list(color="blue")) pt$addRowDataGroups("age", atLevel=1) pt$addRowGroup(caption="Gender", isEmpty=TRUE, isOutline=TRUE, styleDeclarations=list(color="blue")) pt$addRowDataGroups("gender", atLevel=1) pt$defineCalculation(calculationName="GradeCounts", summariseExpression="sum(counts)") pt$evaluatePivot() # pt$renderPivot() # sum(pt$cells$asMatrix(), na.rm=TRUE) # prepStr(as.character(pt$getHtml())) html <- "\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
 ABCDETotal
Age 
199227772375555
2028329067395612
214584123157499908
221366859101615979
Total21820634939718843054
Gender 
F1411372202359461679
M77691291629381375
Total21820634939718843054
" expect_equal(sum(pt$cells$asMatrix(), na.rm=TRUE), 24432) expect_identical(as.character(pt$getHtml()), html) }) } scenarios <- testScenarios("irregular layout tests: combine pivot 4") for(i in 1:nrow(scenarios)) { if(!isDevelopmentVersion) break evaluationMode <- scenarios$evaluationMode[i] processingLibrary <- scenarios$processingLibrary[i] description <- scenarios$description[i] countFunction <- scenarios$countFunction[i] test_that(description, { gender <- c("F", "F", "F", "F", "F", "F", "F", "F", "F", "F", "F", "F", "F", "F", "F", "F", "F", "F", "F", "F", "M", "M", "M", "M", "M", "M", "M", "M", "M", "M", "M", "M", "M", "M", "M", "M", "M", "M", "M", "M") age <- c(19, 19, 19, 19, 19, 20, 20, 20, 20, 20, 21, 21, 21, 21, 21, 22, 22, 22, 22, 22, 19, 19, 19, 19, 19, 20, 20, 20, 20, 20, 21, 21, 21, 21, 21, 22, 22, 22, 22, 22) grade <- c("A", "B", "C", "D", "E", "A", "B", "C", "D", "E", "A", "B", "C", "D", "E", "A", "B", "C", "D", "E", "A", "B", "C", "D", "E", "A", "B", "C", "D", "E", "A", "B", "C", "D", "E", "A", "B", "C", "D", "E") counts <- c(6, 16, 56, 37, 213, 14, 21, 61, 45, 191, 30, 54, 74, 82, 246, 91, 46, 29, 71, 296, 3, 6, 21, 35, 162, 14, 11, 29, 22, 204, 15, 30, 49, 75, 253, 45, 22, 30, 30, 319) df <- data.frame(gender, age, grade, counts) library(pivottabler) pt <- PivotTable$new(processingLibrary=processingLibrary, evaluationMode=evaluationMode) pt$addData(df) pt$addColumnDataGroups("grade") pt$addRowGroup(caption="Age", isEmpty=TRUE, isOutline=TRUE, styleDeclarations=list(color="blue")) pt$addRowDataGroups("age", atLevel=1, addTotal=FALSE) pt$addRowGroup(caption="Gender", isEmpty=TRUE, isOutline=TRUE, styleDeclarations=list(color="blue")) pt$addRowDataGroups("gender", atLevel=1, addTotal=FALSE) pt$defineCalculation(calculationName="GradeCounts", summariseExpression="sum(counts)") pt$addRowGroup(caption="Total", isOutline=TRUE, isTotal=TRUE, isLevelTotal=TRUE, styleDeclarations=list(color="blue"), cellStyleDeclarations=list(color="blue")) pt$evaluatePivot() # pt$renderPivot() # sum(pt$cells$asMatrix(), na.rm=TRUE) # prepStr(as.character(pt$getHtml())) html <- "\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
 ABCDETotal
Age 
199227772375555
2028329067395612
214584123157499908
221366859101615979
Gender 
F1411372202359461679
M77691291629381375
Total21820634939718843054
" expect_equal(sum(pt$cells$asMatrix(), na.rm=TRUE), 18324) expect_identical(as.character(pt$getHtml()), html) }) }