Last active
May 18, 2016 14:52
-
-
Save ajpelu/194e721077ec045a2b864088908e7aca to your computer and use it in GitHub Desktop.
How to get results from multcomp glht object to print as table
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Table for export results of multiple comparison (post hoc Tukey) | |
# Source: Modified from https://gist.github.com/cheuerde/3acc1879dc397a1adfb0 | |
# x is a ghlt object | |
table_glht <- function(x) { | |
pq <- summary(x)$test | |
mtests <- cbind(pq$coefficients, pq$sigma, pq$tstat, pq$pvalues) | |
error <- attr(pq$pvalues, "error") | |
pname <- switch(x$alternativ, less = paste("Pr(<", ifelse(x$df ==0, "z", "t"), ")", sep = ""), | |
greater = paste("Pr(>", ifelse(x$df == 0, "z", "t"), ")", sep = ""), two.sided = paste("Pr(>|",ifelse(x$df == 0, "z", "t"), "|)", sep = "")) | |
colnames(mtests) <- c("Estimate", "Std. Error", ifelse(x$df ==0, "z value", "t value"), pname) | |
return(mtests) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment