Default command line for 1 sample T-test
t.test(x, mu = 0, alternative = "two.sided")
x – numeric vector containing data
mu – theoretical mean
alternative = “two.sided” “greater” “less”
Example: A plant scientist would like to determine if
the heights of maize plants are different from the
average mean height of 180 cm. He sampled randomly from 16 plants.(α = 0.05)
1 sample T-test
x<-c(186,180,176,177,178,181,180,182,183,180,181,
180,180,183,185,181)
t.test(x, mu = 180, alternative = "two.sided")
##
## One Sample t-test
##
## data: x
## t = 1.2317, df = 15, p-value = 0.237
## alternative hypothesis: true mean is not equal to 180
## 95 percent confidence interval:
## 179.4065 182.2185
## sample estimates:
## mean of x
## 180.8125
To change the confidence level, add conf.level =
x<-c(186,180,176,177,178,181,180,182,183,180,181,
180,180,183,185,181)
t.test(x, mu = 180, alternative = "two.sided",conf.level=0.99)
##
## One Sample t-test
##
## data: x
## t = 1.2317, df = 15, p-value = 0.237
## alternative hypothesis: true mean is not equal to 180
## 99 percent confidence interval:
## 178.8687 182.7563
## sample estimates:
## mean of x
## 180.8125