You might modify this function which computes Cramer's V using the assocstats() function in package vcd:
catcor <- function(x) { require(vcd) nc <- ncol(x) v <- expand.grid(1:nc, 1:nc) matrix(mapply(function(i1, i2) assocstats(table(x[,i1], x[,i2]))$cramer, v[,1], v[,2]), nc, nc) } e.g. > dat <- data.frame(v1=sample(LETTERS[1:5], 15, replace=TRUE), + v2=sample(LETTERS[1:5], 15, replace=TRUE), + v3=sample(LETTERS[1:5], 15, replace=TRUE)) > catcor(dat) [,1] [,2] [,3] [1,] 1.0000000 0.5633481 0.5773503 [2,] 0.5633481 1.0000000 0.6831301 [3,] 0.5773503 0.6831301 1.0000000 ------------------------------------- David L Carlson Department of Anthropology Texas A&M University College Station, TX 77840-4352 -----Original Message----- From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On Behalf Of Skála, Zdenek (INCOMA GfK) Sent: Tuesday, February 18, 2014 3:33 AM To: r-help@r-project.org Subject: [R] association of multiple variables Dear all, Please, is there a way in R to calculate association statistics over more than 2 categorical (binary) variables? I mean something similar what cor(my.dataframe) does for continuous variables, i.e. to have a matrix of statistics and/or p-values as an output. Many thanks! Zdenek - - Zdenlk Skala INCOMA GfK [[alternative HTML version deleted]] ______________________________________________ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.