码迷,mamicode.com
首页 > 编程语言 > 详细

【菜鸟入门R语言】独立t检验

时间:2017-02-16 00:09:34      阅读:1183      评论:0      收藏:0      [点我收藏+]

标签:blank   pair   hive   bae   article   gen   test   write   href   

t检验的目的是,比较两组数据有无显著性差异。

知识要点:

我的数据是两种环境下的植物体的生理性状,不是成对的,所以选择独立t检验,并不需要检验方差同质性(homogeneity of variance) 的前提假设,比如Levene’s test,别问我为什么说这么常识性的话。

mtcars <- read.csv(file.choose())
res<-c()
res[1]<-t.test(mtcars$D1_1,mtcars$D2_1,paired = FALSE)$p.value
res[2]<-t.test(mtcars$D1_2,mtcars$D2_2,paired = FALSE)$p.value
res[3]<-t.test(mtcars$D1_3,mtcars$D2_3,paired = FALSE)$p.value
res[4]<-t.test(mtcars$D1_4,mtcars$D2_4,paired = FALSE)$p.value
res[5]<-t.test(mtcars$F1_1,mtcars$F2_1,paired = FALSE)$p.value
res[6]<-t.test(mtcars$F1_2,mtcars$F2_2,paired = FALSE)$p.value
res[7]<-t.test(mtcars$F1_3,mtcars$F2_3,paired = FALSE)$p.value
res[8]<-t.test(mtcars$F1_4,mtcars$F2_4,paired = FALSE)$p.value
res[9]<-t.test(mtcars$L1_1,mtcars$L2_1,paired = FALSE)$p.value
res[10]<-t.test(mtcars$L1_2,mtcars$L2_2,paired = FALSE)$p.value
res[11]<-t.test(mtcars$L1_3,mtcars$L2_3,paired = FALSE)$p.value
res[12]<-t.test(mtcars$L1_4,mtcars$L2_4,paired = FALSE)$p.value
res[13]<-t.test(mtcars$Y1_1,mtcars$Y2_1,paired = FALSE)$p.value
res[14]<-t.test(mtcars$Y1_2,mtcars$Y2_2,paired = FALSE)$p.value
res[15]<-t.test(mtcars$Y1_3,mtcars$Y2_3,paired = FALSE)$p.value
res[16]<-t.test(mtcars$Y1_4,mtcars$Y2_4,paired = FALSE)$p.value
res[17]<-t.test(mtcars$M1_1,mtcars$M2_1,paired = FALSE)$p.value
res[18]<-t.test(mtcars$M1_2,mtcars$M2_2,paired = FALSE)$p.value
res[19]<-t.test(mtcars$M1_3,mtcars$M2_3,paired = FALSE)$p.value
res[20]<-t.test(mtcars$M1_4,mtcars$M2_4,paired = FALSE)$p.value
res[21]<-t.test(mtcars$N1_1,mtcars$N2_1,paired = FALSE)$p.value
res[22]<-t.test(mtcars$N1_2,mtcars$N2_2,paired = FALSE)$p.value
res[23]<-t.test(mtcars$N1_3,mtcars$N2_3,paired = FALSE)$p.value
res[24]<-t.test(mtcars$N1_4,mtcars$N2_4,paired = FALSE)$p.value
res[25]<-t.test(mtcars$T1_1,mtcars$T2_1,paired = FALSE)$p.value
res[26]<-t.test(mtcars$T1_2,mtcars$T2_2,paired = FALSE)$p.value
res[27]<-t.test(mtcars$T1_3,mtcars$T2_3,paired = FALSE)$p.value
res[28]<-t.test(mtcars$T1_4,mtcars$T2_4,paired = FALSE)$p.value

res_m<-matrix(res,4,7);
write.csv(res_m,"d:/doing/res.csv");

  

 

【菜鸟入门R语言】独立t检验

标签:blank   pair   hive   bae   article   gen   test   write   href   

原文地址:http://www.cnblogs.com/liulele622/p/6403622.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!