1.test()函数简介
t.test(x, ...)
## Default S3 method:
t.test(x, y = NULL,
alternative = c("two.sided", "less", "greater"),
mu = 0, paired = FALSE, var.equal = FALSE,
conf.level = 0.95, ...)
参考链接:https://www.jianshu.com/p/d2080c89ccbd
2.示例
#函数t.test();
x<-c(1.9,0.8,1.1,0.1,0.1,4.4,5.5,1.6,4.6,3.4)
y<-c(0.7,-1.6,-0.2,-1.2,-0.1,3.4,3.7,0.8,0.0,2.0)
t.test(x,y)
a <- t.test(x,y)$p.value
会显示一个值 a = 0.739970…
参考链接:https://blog.csdn.net/qq_21814361/article/details/83688406
附:x,y 的长度不一样也能计算。
3.举一个循环的例子,也可以用apply
# a <- c()
# for (i in 1:3) {
# for(j in 1:ncol(ESNP2))
# {
# a <- c(a,t.test(AA[,i],ESNP2[,j],alternative = 'two.sided',var.equal = FALSE)$p.value)
# }
# }
附上:老师说也可以用glm()函数去进行t检验更好。