vcramer <- function (x, y = NULL) { if(!is.null(y)) { tab <- table(x, y) } else tab = as.matrix(x) n <- (min(nrow(tab), ncol(tab))-1) * margin.table(tab) chiq <- as.numeric(chisq.test(tab, correct = FALSE)$statistic) p <- chisq.test(tab, correct = FALSE)$p.value v = sqrt(chiq / n) res <- c("chi.sq" = chiq, "p" = p, "v di Cramer" = v) res }