R语言学习(统计分析数据:T检验中的t.test()函数的学习

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检验更好。

  • 4
    点赞
  • 19
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值