[英]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 個
我發現的教程並沒有將直方圖轉換為 ANOVA 和 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"))
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.