Information you are looking for is simply not returned from a dunn.test. You can try to do something like this: library(dunn.test) #' Return result of dunn.test with groups attached #' #' @param x - a numeric vector, or a list of numeric vectors. #' @param g - a factor variable,...
You could convert your source data.frame to a text matrix, prefix whatever title you want, and write that to file. For example, given this data.frame: dat <- data.frame(Fruit=c('Apple', 'Banana'), Quantity=1:2, Notes=c('Hello', 'Some Text')) You could use a function like this: text_matrix <- function(dat, table_title) { rbind(c(table_title, rep('', ncol(dat)-1)), # title...
Thanks to @ben-bolker and @dickoa, this is the answer to my question: kw <- dunn.test(dat[[1]], as.factor(dat[[2]]), method = "sidak", kw = FALSE) chi2 <- kw$chi2 df <- length(levels(dat[[2]]))-1 P <- pchisq(chi2, df,lower.tail=FALSE) kw <- cbind(colnames(dat[1]), chi2, df, P) kw <- as.data.frame(kw) colnames(kw) <- c("Variable", "chi2", "df", "p") kw ...