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");