Chapter 12 Two Sample t-Test

12.1 Example with Wide Format Data

## 'data.frame':    15 obs. of  2 variables:
##  $ redbeet: num  18 5 10 8 16 12 8 8 11 5 ...
##  $ barley : num  8 5 10 19 15 18 11 8 9 4 ...
##     redbeet          barley    
##  Min.   : 5.00   Min.   : 4.0  
##  1st Qu.: 8.00   1st Qu.: 6.0  
##  Median : 9.00   Median : 8.0  
##  Mean   :10.27   Mean   : 9.6  
##  3rd Qu.:11.50   3rd Qu.:12.0  
##  Max.   :21.00   Max.   :19.0
##   redbeet barley
## 1      18      8
## 2       5      5
## 3      10     10
## 4       8     19
## 5      16     15
## 6      12     18

## 
##  F test to compare two variances
## 
## data:  redbeet and barley
## F = 0.97888, num df = 14, denom df = 14, p-value = 0.9687
## alternative hypothesis: true ratio of variances is not equal to 1
## 95 percent confidence interval:
##  0.3286377 2.9156685
## sample estimates:
## ratio of variances 
##          0.9788762
## 
##  Two Sample t-test
## 
## data:  redbeet and barley
## t = 0.38658, df = 28, p-value = 0.702
## alternative hypothesis: true difference in means is not equal to 0
## 95 percent confidence interval:
##  -2.865852  4.199185
## sample estimates:
## mean of x mean of y 
##  10.26667   9.60000

12.2 Example with Long Format Data

## 'data.frame':    30 obs. of  2 variables:
##  $ remed.pcnt: num  46 50 44 44 43 52 48 24 51 29 ...
##  $ plt.typ   : chr  "cabbage" "cabbage" "cabbage" "cabbage" ...
##    remed.pcnt      plt.typ         
##  Min.   :17.00   Length:30         
##  1st Qu.:29.25   Class :character  
##  Median :34.50   Mode  :character  
##  Mean   :38.17                     
##  3rd Qu.:47.50                     
##  Max.   :61.00
##   remed.pcnt plt.typ
## 1         46 cabbage
## 2         50 cabbage
## 3         44 cabbage
## 4         44 cabbage
## 5         43 cabbage
## 6         52 cabbage

## 
##  F test to compare two variances
## 
## data:  remed.pcnt by plt.typ
## F = 1.1449, num df = 14, denom df = 14, p-value = 0.8037
## alternative hypothesis: true ratio of variances is not equal to 1
## 95 percent confidence interval:
##  0.3843653 3.4100823
## sample estimates:
## ratio of variances 
##           1.144866
## 
##  Two Sample t-test
## 
## data:  remed.pcnt by plt.typ
## t = 3.4687, df = 28, p-value = 0.00171
## alternative hypothesis: true difference in means between group cabbage and group maize is not equal to 0
## 95 percent confidence interval:
##   5.377502 20.889165
## sample estimates:
## mean in group cabbage   mean in group maize 
##              44.73333              31.60000