# R语言之t检验

> t.test(data2,mu=5)

One Sample t-test

data:  data2
t = 0.25482, df = 15, p-value = 0.8023
alternative hypothesis: true mean is not equal to 5
95 percent confidence interval:
4.079448 6.170552
sample estimates:
mean of x
5.125

> t.test(data2,data3,var.equal = TRUE)

Two Sample t-test

data:  data2 and data3
t = -2.7908, df = 26, p-value = 0.009718
alternative hypothesis: true difference in means is not equal to 0
95 percent confidence interval:
-3.5454233 -0.5379101
sample estimates:
mean of x mean of y
5.125000  7.166667

> t.test(data2,data3,var.equal = FALSE)

Welch Two Sample t-test

data:  data2 and data3
t = -2.8151, df = 24.564, p-value = 0.009462
alternative hypothesis: true difference in means is not equal to 0
95 percent confidence interval:
-3.5366789 -0.5466544
sample estimates:
mean of x mean of y
5.125000  7.166667

> t.test(data1,data2,paired = TRUE)

rich graze
1   12   mow
2   15   mow
3   17   mow
4   11   mow
5   15   mow
6    8 unmow
7    9 unmow
8    7 unmow
9    9 unmow

> t.test(rich~graze,data=grass)

Welch Two Sample t-test

data:  rich by graze
t = 4.8098, df = 5.4106, p-value = 0.003927
alternative hypothesis: true difference in means is not equal to 0
95 percent confidence interval:
2.745758 8.754242
sample estimates:
mean in group mow mean in group unmow
14.00                8.25

> t.test(rich~graze,data=grass,subset=graze%in%c("mow","unmow"))

Welch Two Sample t-test

data:  rich by graze
t = 4.8098, df = 5.4106, p-value = 0.003927
alternative hypothesis: true difference in means is not equal to 0
95 percent confidence interval:
2.745758 8.754242
sample estimates:
mean in group mow mean in group unmow
14.00                8.25

R语言之t检验

(0)
(0)

0条