From 71ce0d6a7210eac268567d9cdd507fb6e93bcccb Mon Sep 17 00:00:00 2001 From: Elin Waring Date: Sun, 26 Jul 2026 16:40:47 -0400 Subject: [PATCH] Add function for chi square. --- R/data_chisq.R | 15 +++++++++++++++ 1 file changed, 15 insertions(+) create mode 100644 R/data_chisq.R diff --git a/R/data_chisq.R b/R/data_chisq.R new file mode 100644 index 000000000..636f87bea --- /dev/null +++ b/R/data_chisq.R @@ -0,0 +1,15 @@ +#' Calculate chi square test for tabulate +#' +#' @param dwtable A dwtable object. +#' @param show_table Should the table be shown with the chi sqare +#' @param ... Other options +#' +#' @export +data_chisq <- function(dwtable, show_table = TRUE, ...) { + tablelist <- as.table(dwtable) + chisqlist <- lapply(tablelist, stats::chisq.test) + if (length(chisqlist) == 1) { + return(chisqlist[[1]]) + } + chisqlist +}