One-sample t-test

One-sample t-test

Working Directory

setwd("/Volumes/EDMS451/Software Instructions")

Manually Enter Data

dat <- data.frame(var1 = c(4.1, 5.2, 7.5, 8.2, 9.3, 3.1, 1.6,
                           6.0, 7.4, 6.5, 5.1, 9.6, 2.8, 5.9,
                           5.1, 1.2, 2.5, 5.4, 7.7, 8.9, 3.0
                           ))
colnames(dat) <- "June1234"   # change the variable name

dat                           # view the data
   June1234
1       4.1
2       5.2
3       7.5
4       8.2
5       9.3
6       3.1
7       1.6
8       6.0
9       7.4
10      6.5
11      5.1
12      9.6
13      2.8
14      5.9
15      5.1
16      1.2
17      2.5
18      5.4
19      7.7
20      8.9
21      3.0

One-sample t-test

t.test(dat$June1234, alternative = "two.sided", mu = 5, conf.level = 0.99)

    One Sample t-test

data:  dat$June1234
t = 0.95626, df = 20, p-value = 0.3504
alternative hypothesis: true mean is not equal to 5
99 percent confidence interval:
 3.955815 7.101328
sample estimates:
mean of x 
 5.528571 


A slightly different set-up:

t.test(dat$June1234, alternative = "two.sided", mu = 0, conf.level = 0.95)

    One Sample t-test

data:  dat$June1234
t = 10.002, df = 20, p-value = 3.153e-09
alternative hypothesis: true mean is not equal to 0
95 percent confidence interval:
 4.375559 6.681584
sample estimates:
mean of x 
 5.528571