testlib is a demo R package created to explore the different aspects of R package development. Hadley Wickham's book R Packages was used as a guide for developing this package. The package contains a function for creating two way tables of categorical data and visualizing such tables using bar and mosaic plots. Learn more in vignette("testlib")
or ?cross_table
.
testlib is not currently available from CRAN, but you can install the development version from github:
# install.packages("devtools")
devtools::install_github("rsquaredacademy/testlib")
The main function in the pacakge is cross_table()
which creates two way tables of categorical data.
library(testlib)
k <- testlib::cross_table(mtcars$cyl, mtcars$am)
k
## Cell Contents
## |---------------|
## | Frequency |
## | Percent |
## | Row Pct |
## | Col Pct |
## |---------------|
##
## Total Observations: 32
##
## -------------------------------------------------------------
## | | am |
## -------------------------------------------------------------
## | cyl | 0 | 1 | Row Total |
## -------------------------------------------------------------
## | 4 | 3 | 8 | 11 |
## | | 0.094 | 0.25 | |
## | | 0.27 | 0.73 | 0.34 |
## | | 0.16 | 0.62 | |
## -------------------------------------------------------------
## | 6 | 4 | 3 | 7 |
## | | 0.125 | 0.094 | |
## | | 0.57 | 0.43 | 0.22 |
## | | 0.21 | 0.23 | |
## -------------------------------------------------------------
## | 8 | 12 | 2 | 14 |
## | | 0.375 | 0.062 | |
## | | 0.86 | 0.14 | 0.44 |
## | | 0.63 | 0.15 | |
## -------------------------------------------------------------
## | Column Total | 19 | 13 | 32 |
## | | 0.594 | 0.406 | |
## -------------------------------------------------------------