Two factors each with two levels.
A | B | label |
---|---|---|
- | - | (1) |
+ | - | a |
- | + | b |
+ | + | ab |
label | effect A | effect B | effect AB |
---|---|---|---|
(1) | - | - | + |
a | + | - | - |
b | - | + | - |
ab | + | + | + |
library(readr)
library(dplyr)
yield <- read_table2("https://uwmadison.box.com/shared/static/bfwd6us8xsii4uelzftg1azu2f7z77mk.txt")
facet_wrap
in ggplot
to split a plot of the data into separate panels or use the base R interaction.plot
function. Both plots show how the effect of factor A varies as the value of factor B changes. In this case, the effect of factor A is slightly smaller (lower slope) when factor B isB inactive. In the next lecture though, we’ll see that this difference is not significant (it could very well happen by change under the model with no interaction term).ggplot(yield) +
geom_point(aes(A, Yield)) +
facet_wrap(~B)
interaction.plot(yield$A, yield$B, yield$Yield)