- 1 Menu items
- 2 Randomized Complete Block Design (RCBD)
- 2.1 Data
- 2.2
**(2 p)**Reshape and plot the data, describe relationships of Sales between Items and Restaurants - 2.3
**(0 p)**Fit model - 2.4
**(3 p)**Assess model assumptions - 2.5
**(2 p)**State and interpret the hypothesis test for difference in Item mean sales - 2.6
**(2 p)**If appropriate, perform pairwise comparisons with Tukey HSD correction - 2.7
**(1 p)**What is your recommendation to the Franchise?

Following the in-class assignment this week, perform a complete RCBD analysis.

- (2 p) Reshape and plot the data, describe relationships of Sales between Items and Restaurants
- (0 p) Fit model
- (3 p) Assess model assumptions
- (2 p) State and interpret the hypothesis test for difference in Item mean sales
- (2 p) If appropriate, perform pairwise comparisons with Tukey HSD correction
- (1 p) What is your recommendation to the Franchise?

```
library(tidyverse)
# load ada functions
source("ada_functions.R")
# read the data
<- read.table(text="
dat_food Restaurant Item1 Item2 Item3
A 31 27 24
B 31 28 31
C 45 29 46
D 21 18 48
E 42 36 46
F 32 17 40
", header = TRUE) %>%
as_tibble()
```

The code below will get you started with reshaping the data. The rest is up to you!

```
<-
dat_food_long %>%
dat_food pivot_longer(
cols = starts_with("Item")
names_to = "Item"
, values_to = "Sales"
, %>%
) mutate(
Item = factor(Item)
Restaurant = factor(Restaurant)
,
)
str(dat_food_long)
```

```
tibble [18 x 3] (S3: tbl_df/tbl/data.frame)
$ Restaurant: Factor w/ 6 levels "A","B","C","D",..: 1 1 1 2 2 2 3 3 3 4 ...
$ Item : Factor w/ 3 levels "Item1","Item2",..: 1 2 3 1 2 3 1 2 3 1 ...
$ Sales : int [1:18] 31 27 24 31 28 31 45 29 46 21 ...
```

```
# Group means
<-
m_dat_b %>%
dat_food_long group_by(Item) %>%
summarize(
m = mean(Sales)
) m_dat_b
```

```
# A tibble: 3 x 2
Item m
<fct> <dbl>
1 Item1 33.7
2 Item2 25.8
3 Item3 39.2
```

```
<-
m_dat_c %>%
dat_food_long group_by(Restaurant) %>%
summarize(
m = mean(Sales)
) m_dat_c
```

```
# A tibble: 6 x 2
Restaurant m
<fct> <dbl>
1 A 27.3
2 B 30
3 C 40
4 D 29
5 E 41.3
6 F 29.7
```