我进行了Wilcoxon检验,现在我想将p.value提取到列表或矩阵中。
DF <- data.frame(A1=sample(1:9, 10, T),
A2=sample(1:9, 10, T),
A3=sample(1:9, 10, T),
B1=sample(1:9, 10, T),
B2=sample(1:9, 10, T),
B3=sample(1:9, 10, T))
sampA <- DF[,grep('A', names(DF))] # Sample with columns A
sampB <- DF[,grep('B', names(DF))] # Sample with columns B
lapply(1:nrow(DF), function(i){
wilcox.test(as.numeric(sampA[i,]), as.numeric(sampB[i,]), exact=FALSE )
})
每行Wilcox检验的结果如下所示: 我想知道如何将p.value以列表或矩阵的形式导出到Excel文件中。 [[1]]
Wilcoxon rank sum test with continuity correction
data: as.numeric(sampA[i, ]) and as.numeric(sampB[i, ])
W = 3, p-value = 0.6579
alternative hypothesis: true location shift is not equal to 0
[[2]]
Wilcoxon rank sum test with continuity correction
data: as.numeric(sampA[i, ]) and as.numeric(sampB[i, ])
W = 0, p-value = 0.0722
alternative hypothesis: true location shift is not equal to 0
[[3]]
Wilcoxon rank sum test with continuity correction
data: as.numeric(sampA[i, ]) and as.numeric(sampB[i, ])
W = 6, p-value = 0.6579
alternative hypothesis: true location shift is not equal to 0
sapply
的相同想法),赞一个! :-) - Simon O'Hanlon