为什么我的Tukey测试(来自Agricolae)为空?

时间:2019-06-21 15:47:31

标签: r statistics tukey tukeyhsd

我正在尝试使用Agricolae软件包中的HSD.test对我的数据进行Tukey的测试。但是,我的结果始终只是单词NULL

我的数据:

structure(list(Sample = c(1011L, 1012L, 1014L, 1024L, 1025L, 
    1026L), Collection = c(1L, 1L, 1L, 1L, 1L, 1L), Irrigation = structure(c(3L, 
    3L, 3L, 5L, 5L, 5L), .Label = c("Rate1", "Rate2", "Rate3", "Rate4", 
    "Rate5"), class = "factor"), Variety = structure(c(2L, 1L, 3L, 
    3L, 2L, 1L), .Label = c("Hodag", "Lamoka", "Snowden"), class = "factor"), 
    Suc = c(0.7333, 0.4717, 0.5883, 0.6783, 0.8283, 0.6833), 
    Gluc = c(0.03, 0.04, 0.043, 0.075, 0.057, 0.087), L = c(59.48, 
    57.59, 59.25, 66.45, 68.29, 65.65), a = c(4.36, 6.85, 3.43, 
    1.7, 0.78, 2.84), b = c(26.82, 27.6, 26.2, 26.14, 25.37, 
    27.19), NoDefect = c(100L, 100L, 100L, 92L, 100L, 100L), 
    Defect = c(0L, 0L, 0L, 8L, 0L, 0L)), row.names = c(NA, 6L
), class = "data.frame")

结合收集和灌溉因素(我想对两种收集类型和5种灌溉类型的这10种总处理方法中的一组进行Tukey的处理):

Tukey_data <- data %>%
      mutate(Tukey_ID = paste(Collection, Irrigation, sep="_"))

Anova:

Tukey_data$Tukey_ID <- as.factor(Tukey_data$Tukey_ID) 
TukeyAov <- aov(Suc ~ Tukey_data$Tukey_ID, data = Tukey_data)

Tukey的:

HSD.test(TukeyAov, "Tukey_ID", group=FALSE)

响应:NULL

有人知道为什么我的回答为空吗?非常感谢!

1 个答案:

答案 0 :(得分:0)

我遇到了同样的问题,发现处理变量需要完全按照模型中的标签进行标记。它将其读取为字符串,而不是标签。在您的情况下,您需要 trt = "Tukey_data$Tukey_ID"。在另一个例子中,当我定义我的模型时,我使用了 as.factor(Tukey_ID) 并且需要将处理定义为 trt = "as.factor(Tukey_ID)"