我想从glht对象中获取p值和相关因素(最后是示例代码)。
summary(mcptu)$test$pvalues适用于p值,但rownames(summary(mcptu)$linfct)很棘手。
使用rownames(summary(mcptu)$linfct),我可以得到“2-1”“3-1”“4-1”“5-1”“6-1”“3-2”,等等。但是,也许有一种优雅的方法可以比较这些因素呢?
library(mratios); library(multcomp)
data(Penicillin)
Penicillin$strain <- as.factor(Penicillin$strain)
linmod <- lm(diameter ~ strain, Penicillin)
mcptu <- glht(linmod, mcp(strain="Tukey"))
summary(mcptu)克里斯多夫
发布于 2014-07-07 11:11:28
这对是(2,1),(3,1),.(n,1),然后(3,2),.(n,2),(n,n)。使用seq和rep变体创建它们。
get_level_pairs <- function(n)
{
data.frame(
x = unlist(lapply(seq_len(n)[-1], seq.int, to = n)),
y = rep.int(seq_len(n - 1), rev(seq_len(n - 1)))
)
}
get_level_pairs(nlevels(Penicillin$strain))或者分开那些行名。
library(stringr)
str_split_fixed(rownames(mcptu$linfct), " - ", 2)https://stackoverflow.com/questions/24608520
复制相似问题