Following the in-class assignment this week, perform a complete RCBD analysis.
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)
)
str(dat_food_long)
Classes 'tbl_df', 'tbl' and 'data.frame': 18 obs. of 3 variables:
$ 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 31 27 24 31 28 31 45 29 46 21 ...
# A tibble: 3 x 2
Item m
<fct> <dbl>
1 Item1 33.7
2 Item2 25.8
3 Item3 39.2
# 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