简体   繁体   English

如何对R中的raitos(两对数据)进行t检验?

[英]How to do t-test of raitos (two pairs of data) in R?

I have a dataframe of five columns,something like this:我有一个五列的 dataframe,如下所示:

在此处输入图像描述

I want to do t-test of A2/A1 vs B2/B1.我想做 A2/A1 与 B2/B1 的 t 检验。 One method I can think about is first calculte the ratios and make a new column C=A2/A1 and D=B2/B1 .我可以考虑的一种方法是首先计算比率并创建一个新列C=A2/A1D=B2/B1 Then do t-test of C vs D. But is this the correct way to do so?然后对 C 与 D 进行 t 检验。但这是正确的方法吗? Or if there is another way to use the original data for comparison?或者是否有另一种方法可以使用原始数据进行比较? Thanks!谢谢!

This will perform a paired t-test.这将执行配对 t 检验。

text="Gene A1 A2 B1 B2
gene1 100 20 2 20
gene2 10 200 2 200
gene3 10 2 2 2"
df=read.table(text=text, header=TRUE)
df[,"C"]=df[,"A2"]/df[,"A1"]
df[,"D"]=df[,"B2"]/df[,"B1"]
t.test(df[,"C"], df[,"D"], paired=TRUE)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM