如何在 R 中的直方图数据帧上进行方差分析和 Tukey 的 HSD

How to do ANOVA and Tukey's HSD on histogram dataframe in R

我使用以下代码在一个数据框中有几个 tidyr“未计数”直方图:

#read in csv's to list
temp = list.files(pattern="*.csv")
myfiles = lapply(temp, read.csv)

#uncount data. (original c1 ->c3 = frequency, value, variable)
#              (now c1, c2 = value, variable)
new_files <- lapply(myfiles, function(x) {
  names(x) <- c("EVI", "Frequency", "Transition")
  tidyr::uncount(x, Frequency)
})

list(temp)


#take the list of histogram and concatenate them
data_c <- do.call("rbind", new_files)
head(data_c)

第 1 列“EVI”包含每个值的计数,第 2 列是给定直方图的变量,其中有 9

我找到的教程没有介绍如何将直方图转换为方差分析和 Tukey HSD,因此非常感谢您的帮助!

从“uncount data”代码块之后开始:

#take the list of histogram and concatenate them
data_c <- do.call("rbind", new_files)
head(data_c)
#dplyr::sample_n(data_c, 10)

#Conduct ANOVA and the TukeyHSD
data_c$EVI<-as.numeric(data_c$EVI)
aov_m1<-aov(EVI~Transition, data=data_c)
(THSD_m1<-TukeyHSD(aov_m1, "Transition"))