母平均の検定

x <- c(-2, -4, -1, 4)

t.test(x, alternative = "less")
## 
##  One Sample t-test
## 
## data:  x
## t = -0.44073, df = 3, p-value = 0.3446
## alternative hypothesis: true mean is less than 0
## 95 percent confidence interval:
##      -Inf 3.254753
## sample estimates:
## mean of x 
##     -0.75
x <- c(-2, -4, -2, 4)

t.test(x, alternative = "less")
## 
##  One Sample t-test
## 
## data:  x
## t = -0.57735, df = 3, p-value = 0.3021
## alternative hypothesis: true mean is less than 0
## 95 percent confidence interval:
##      -Inf 3.076145
## sample estimates:
## mean of x 
##        -1

母平均の差の検定(2標本t検定)

x <- c(-2, -4, -1, 4)
x <- c(1, 2, 3, 4, 5)
y <- c(4, 5, 6, 7)

t.test(x, y)
## 
##  Welch Two Sample t-test
## 
## data:  x and y
## t = -2.6112, df = 6.9808, p-value = 0.03494
## alternative hypothesis: true difference in means is not equal to 0
## 95 percent confidence interval:
##  -4.7652203 -0.2347797
## sample estimates:
## mean of x mean of y 
##       3.0       5.5

母平均の差の検定(対標本t検定)

x <- c(70, 45, 98, 82)
y <- c(81, 50, 76, 78)

t.test(y, x, paired = T)
## 
##  Paired t-test
## 
## data:  y and x
## t = -0.34752, df = 3, p-value = 0.7512
## alternative hypothesis: true mean difference is not equal to 0
## 95 percent confidence interval:
##  -25.39371  20.39371
## sample estimates:
## mean difference 
##            -2.5