When using rpivotTable, I noticed that for aggregated data that are equal to 0, the cell shows up blank. To me, the blank signifies missing data, not a true zero value.
Here start up the library and show the sessionInfo():
library( rpivotTable )
sessionInfo()
## R version 3.4.2 (2017-09-28)
## Platform: x86_64-w64-mingw32/x64 (64-bit)
## Running under: Windows 10 x64 (build 14393)
##
## Matrix products: default
##
## locale:
## [1] LC_COLLATE=English_United States.1252
## [2] LC_CTYPE=English_United States.1252
## [3] LC_MONETARY=English_United States.1252
## [4] LC_NUMERIC=C
## [5] LC_TIME=English_United States.1252
##
## attached base packages:
## [1] stats graphics grDevices utils datasets methods base
##
## other attached packages:
## [1] rpivotTable_0.2.0
##
## loaded via a namespace (and not attached):
## [1] htmlwidgets_0.9 compiler_3.4.2 backports_1.1.1 magrittr_1.5
## [5] rprojroot_1.2 tools_3.4.2 htmltools_0.3.6 yaml_2.1.14
## [9] Rcpp_0.12.13 stringi_1.1.6 rmarkdown_1.8 knitr_1.17
## [13] stringr_1.2.0 digest_0.6.12 evaluate_0.10.1
Here I create a dummy data table.
# dummy data frame for testing.
x <- data.frame(which_letter=letters[1:5], is_vowel=c(1,0,0,0,1))
x
## which_letter is_vowel
## 1 a 1
## 2 b 0
## 3 c 0
## 4 d 0
## 5 e 1
Here’s a little demo which shows that the averaging works overall:
When I disaggregate over which_letter, then the averages that should be “0.0” turn to blanks:
rpivotTable(
x,
rows = c( "which_letter" ),
aggregatorName = "Average", vals="is_vowel"
)
But here, as we can see, the aggregated rows function correctly when the resulting value is non-zero.
rpivotTable(
x,
aggregatorName = "Average", vals="is_vowel"
)