getwd()
[1] "/Users/jaclynbazsika/Documents/Documents/MSDS650/w2"
df2 = read.table("fastfood-2.txt", header=TRUE)
r = c(t(as.matrix(df2)))
r
[1] 31 27 24 31 28 31 45 29 46 21 18 48 42 36 46 32 17 40
t(df2)
[,1] [,2] [,3] [,4] [,5] [,6]
Item1 31 31 45 21 42 32
Item2 27 28 29 18 36 17
Item3 24 31 46 48 46 40
f = c("Item1", "Item2", "Item3")
k = 3
n = 6
tm = gl(k, 6, n*k, factor(f))
tm
[1] Item1 Item1 Item1 Item1 Item1 Item1 Item2 Item2 Item2 Item2 Item2 Item2 Item3 Item3 Item3 Item3 Item3 Item3
Levels: Item1 Item2 Item3
blk = gl(n, k, k*n)
blk
[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
av = aov(r ~ tm + blk)
summary(av)
Df Sum Sq Mean Sq F value Pr(>F)
tm 2 538.8 269.39 4.959 0.0319 *
blk 5 559.8 111.96 2.061 0.1547
Residuals 10 543.2 54.32
---
Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
With the P-value >0.05(blk), it can be concluded that the null hypothesis can not be rejected. However, for tm, the p-value is < 0.05. This would render the data statistically insignifcant; therefore, the null hypothesis is rejected. For tm, the mean sales volume of new menu items are all equal. For blk, the mean sales volume is not equal.