Load the library

library(daewr)

Sales represent restaurant sales

6 blocks of restaurants and 3 treatment factors (menu items)

# menu items
items <- factor(rep(c(1, 2, 3), each = 1))
items
## [1] 1 2 3
## Levels: 1 2 3
# blocks
blocks <- factor(rep(c(1, 2, 3, 4, 5, 6), each = 3))
blocks
##  [1] 1 1 1 2 2 2 3 3 3 4 4 4 5 5 5 6 6 6
## Levels: 1 2 3 4 5 6
block2 <- 

# sales figures
sales <- c(31, 27, 24, 
           31, 28, 31,
           45, 29, 46, 
           21, 18, 48, 
           42, 36, 46, 
           32, 17, 40)
sales
##  [1] 31 27 24 31 28 31 45 29 46 21 18 48 42 36 46 32 17 40
# combine
df <- data.frame(blocks, sales, items)
df

Anova

Ho: u1 = u2 = u3

Ha: at least one of the treatment factor is significant

Tukey HSD shows us that 3 - 2 for items is significant

summary(mod <- aov(sales ~ blocks + items, data = df))
##             Df Sum Sq Mean Sq F value Pr(>F)  
## blocks       5  559.8  111.96   2.061 0.1547  
## items        2  538.8  269.39   4.959 0.0319 *
## Residuals   10  543.2   54.32                 
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
TukeyHSD(mod, "blocks")
##   Tukey multiple comparisons of means
##     95% family-wise confidence level
## 
## Fit: aov(formula = sales ~ blocks + items, data = df)
## 
## $blocks
##            diff        lwr       upr     p adj
## 2-1   2.6666667 -18.235335 23.568669 0.9971568
## 3-1  12.6666667  -8.235335 33.568669 0.3559810
## 4-1   1.6666667 -19.235335 22.568669 0.9997013
## 5-1  14.0000000  -6.902002 34.902002 0.2676025
## 6-1   2.3333333 -18.568669 23.235335 0.9984869
## 3-2  10.0000000 -10.902002 30.902002 0.5815802
## 4-2  -1.0000000 -21.902002 19.902002 0.9999758
## 5-2  11.3333333  -9.568669 32.235335 0.4620926
## 6-2  -0.3333333 -21.235335 20.568669 0.9999999
## 4-3 -11.0000000 -31.902002  9.902002 0.4909865
## 5-3   1.3333333 -19.568669 22.235335 0.9998999
## 6-3 -10.3333333 -31.235335 10.568669 0.5508770
## 5-4  12.3333333  -8.568669 33.235335 0.3809386
## 6-4   0.6666667 -20.235335 21.568669 0.9999968
## 6-5 -11.6666667 -32.568669  9.235335 0.4340602
TukeyHSD(mod, "items")
##   Tukey multiple comparisons of means
##     95% family-wise confidence level
## 
## Fit: aov(formula = sales ~ blocks + items, data = df)
## 
## $items
##          diff        lwr       upr     p adj
## 2-1 -7.833333 -19.498312  3.831645 0.2061328
## 3-1  5.500000  -6.164978 17.164978 0.4305650
## 3-2 13.333333   1.668355 24.998312 0.0262709