这是中提到broom的网站,它可以被用于TukeyHSD和multcomp(见这里)。但是,我无法弄清楚如何使用broomforTukeyHSD和multcomp。
请参阅下面给出的 MWE。
df1 <- data.frame(
Rep = factor(rep(1:3, each = 4, times = 2)),
Trt = rep(paste0("T", 1:4), times = 6),
Loc = rep(paste0("Loc", 1:2), each = 12),
Y = rnorm(24)
)
library(dplyr)
df2 <- filter(df1, Loc=="Loc1")
fm1 <- aov(Y ~ Rep + Trt , data = df2)
anova(fm1)
library(multcompView)
fm1Tukey1 <-
data.frame(Letter = multcompLetters(TukeyHSD(fm1)$Trt[, "p adj"])$Letters)
fm1Tukey <- data.frame(Trt = row.names(fm1Tukey1), fm1Tukey1)
fm1Means1 <- …Run Code Online (Sandbox Code Playgroud) 所以我已经将multcomp和multcompview包安装到 RStudio 中;但是,当我使用 cld 函数时,我不断收到此错误
Error in UseMethod("cld") :
no applicable method for 'cld' applied to an object of class "data.frame"
Run Code Online (Sandbox Code Playgroud)
我的数据如下:
Group1 <- c(12.4,10.7,11.9,11.0,12.4,12.3,13.0,12.5,11.2,11.1)
Group2 <- c(8.1,11.5,11.3,8.7,12.7,10.7,9.6,11.3,11.1,13.7)
Group3 <- c(8.5,11.6,10.2,10.9,9.0,9.6,9.9,11.3,10.5,14.2)
Group4 <- c(8.7,9.3,8.2,8.3,9.0,9.4,9.2,12.2,8.5,12.9)
Group5 <- c(12.7,13.2,11.8,11.9,12.2,11.2,13.7,11.8,11.5,9.7)
Combined_Groups<-data.frame(cbind(Group1,Group2,Group3,Group4,Group5))
Combined_Groups #shows spreadsheet like results
summary(Combined_Groups) #min, median, mean, max
Stacked_Groups <- stack(Combined_Groups)
Stacked_Groups #shows the table Stacked_Groups
Anova_Results<-aov(values~ind,data=Stacked_Groups)
summary(Anova_Results) #shows Anova_Results
qf (.95, df1=4, df2=45) #this gives you the critical mean of the F
distribution
t(apply(Combined_Groups, 2, …Run Code Online (Sandbox Code Playgroud)