我是R的新手,我一直在尝试对我的庞大数据集进行Wilcoxon符号秩检验。下面是我的样本的代表
sample Abiotrophia Abyssicoccus Acaryochloris yield day season
R11P4_BS 0.454828660436137 8.71569632259294 0 low 60 2
R13P1_BS 0.013239875389408 10.8649859288577 0.147574819401445 high 60 1
R13P3_BS 0 5.13545281606475 0.386996904024768 low 30 1
我想比较并获得样本组的p值(例如:利用Wilcoxon符号秩和检验(Wilcoxon Signed Rank Test)对3种细菌(Abyssicoccus albus、Acaryochloris marina、Acetilactobacillus jinshanensis)的产率(产量高、产量低)进行比较,最终确定哪些细菌的产率高、产量低。
> dput(head(dat))
structure(list(Abiotrophia = c(0, 3.21408045977011, 0.117816091954023,
0, 0.002873563218391, 0), Abyssicoccus = c(0.454828660436137,
0.013239875389408, 0, 0, 0, 0.007009345794393), Acaryochloris = c(8.71569632259294,
10.8649859288577, 5.13545281606475, 5.72940386089162, 0.888392623745432,
3.93946335292641), day = c(0L, 60L, 60L, 60L, 90L, 90L), yield = c("low",
"high", "high", "low", "high", "high"), season = c(1L, 1L,
1L, 1L, 1L, 1L)), row.names = c("R11P4_BS", "R13P1_BS", "R13P3_BS",
"R13P6_BS", "R14P1_BS", "R14P3_BS"), class = "data.frame")
这是我到目前为止所做的,我相信这显示了第7行数据的p值
wilcox.test(data[data$yield == "low", 7],
data[data$yield == "high", 7], exact=FALSE)$p.val
[1]0.09657031
下面的代码给了我错误:
sapply(2:ncol(data),
function(x) {
wilcox.test(data[data$yield == "low", 7],
data[data$yield == "high", 7], exact=FALSE)$p.val
}
)
任何帮助都将不胜感激。谢谢
1条答案
按热度按时间irlmq6kh1#
当你说“巨大”时,如果你的意思是你有很多行,也许这种方法会适合:
创建于2023-04-05使用reprex v2.0.2
如果你有很多物种,这里有一个不同的选择:
创建于2023-04-05使用reprex v2.0.2