【发布时间】:2015-03-23 01:57:47
【问题描述】:
我有一组数据x,由 12 列和 167 行组成。第一列是每一行的化合物 ID。我想将 3 列作为一组运行 t.test,将其他 3 组作为第二组运行,分别针对每一行。我的代码如下,但它不起作用。
for (i in 1:nrow(x)) {
function(i)c(compound=i,
t.test(x[2:4],x[8:10],
x[x$compound==i, ],
alternative='two.sided',conf.level=0.95)
)
}
print(c(compound=i,t.test(x[2:4],x[8:10],x[x$compound==i,],
alternative='two.sided',conf.level=0.95)))
我的意图是为 AC 组和 SC 组之间的每种代谢物(化合物)做一个t.test,这是两组细胞。
compound AC-1 AC-2 AC-3 AM-1 AM-2 AM-3 SC-1 SC-2 SC-3 SM-1 SM-2 SM-3
alanine 27612820 22338050 15359640 19741350 18726880 18510800 10914980 12071660 16036180 16890860 16066960 16364300
arginine 7067206 7172234 5933320 136272600 131596800 134717600 6102838 7186256 6770344 140127100 155341300 151748000
asparagine 3151398 2141378 1240904 11522180 8907711 9842342 1677299 2265826 2942991 11690360 12552660 12102620
【问题讨论】:
-
您想每次都对 3 个值应用 t 检验吗?
-
Neve 只是说“我的代码不起作用”。如果您收到错误,请包含错误消息。如果您没有得到预期的结果,请说出您的预期。此外,您的问题应包括reproducible example,理想情况下应包含示例数据,以便我们可以运行代码并获得与您相同的结果。
-
对三个简单的项目进行单样本 t 检验没有“统计”意义。代码可能会运行,但结果只是“处理过的废话”。
标签: r dataframe statistics t-test hypothesis-test