** I am using the following way to get p-values from fiser exact test. However, I do need to print for each pair the values "n00, n01, n10, n11". How can I print that as a table and not a matrix as below along with the p-value? Any help will be greatly appreciated
fish <- function(y, x) {n00 = sum((1-x)*(1-y)); n01 = sum((1-x)*y); n10 = sum(x*(1-y)); n11 = sum(x*y); a = matrix(c(n00, n01, n10, n11), nrow = 2); pval = fisher.test(a)$p.value; return(pval);} chiArray <- function(x) { apply(mat1, 1, fish, x); } sapply(1:nrow(mat2), function(j){chiArray(mat2[j, ]);}); chisq.cna.mut.test <- sapply(1:nrow(mat2), function(j){chiArray(mat2[j, ]);}); I want output to be: name1_mat1 name1_mat2 n00 n01 n10 n11 pvalue name1_mat1 name2_mat2 n00 n01 n10 n11 pvalue [[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.