add.tables | R Documentation |
Add stat table to an existing contingency table
add.tables(x, format = NULL, ...)
x |
A crosstable object |
format |
Character vector with the format of the stats. See help("%f%") |
... |
A list of tables. They must have the same dimensions of the original table. |
library(magrittr) bacteria <- MASS::bacteria tab <- xtabs(~y+trt, data=bacteria) tab_chsq <- chisq.test(tab) crosstable(tab) %>% add.tables(format=c("0.00%", "(0.00)"), "%" = prop.table(tab)*100, "expected" = tab_chsq$expected)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.