我写了一个脚本,使用来测试数据wilcox.test
,但是当我得到结果时,所有p值都等于1。我在一些网站上读到,在测试数据之前,您可能会使用抖动(以避免像他们所说的那样束缚),我做到了,现在我得到了可以接受的结果。这样做是错误的吗?
test<- function(column,datacol){
library(ggplot2)
t=read.table("data.txt", stringsAsFactors=FALSE)
uni=unique(c(t$V9))
for (xp in uni) {
for(yp in uni) {
testx <- subset(t, V9==xp)
testy <- subset(t, V9==yp)
zz <- wilcox.test(testx[[datacol]],jitter(testy[[datacol]]))
p.value <- zz$p.value
}
}
}
这是输出
dput(head(t))
structure(list(V1 = c(0.268912,
0.314681, 0.347078, 0.286945,
0.39562, 0.282182), V2 = c(0.158921, 0.210526, 0.262024, 0.322006,
0.133417, 0.283025), V3 = c(0.214082, 0.166895, 0.132547, 0.147361,
0.09174, 0.169093), V4 = c(0.358085, 0.307898, 0.258352, 0.243688,
0.379224, 0.2657), V5= c(-0.142223, 0.010895, 0.14655,
0.08152, 0.02116, 0.030083), V6 = c(0.096408, -0.091896,
-0.331229, -0.446603, -0.088493, -0.262037), V7` = c(1.680946,
1.649559, 1.534401, 1.130529, 3.441356, 1.211815), V8 = c("NC_000834", "NC_000844",
"NC_000845", "NC_000846", "NC_000857",
"NC_000860" ), V9 = c("Chordata",
"Arthropoda", "Chordata", "Chordata",
"Arthropoda", "Chordata"), V10 =
c("???:???", "Diplostraca",
"???:???", "Rheiformes", "Diptera",
"Salmoniformes"), V11 = c("???:???",
"Branchiopoda", "Mammalia", "Aves",
"Insecta", "Actinopterygii" )), .Names
= c("V1", "V2", "V3", "V4", "V5", "V6", "V7",
"V8", "V9", "V10",
"V11"), row.names = c(NA, 6L),
class = "data.frame")
数据非常大,这就是我启动的线程,他们告诉我这样做可能是错误的
注意此问题来自tex.SE: 乳胶表内生成PDFcontain R输出
dput()
功能而无需这样做的时候。请提供可复制的示例以获取帮助。