To run a two-way ANOVA in R, you can use the aov()
function. Here is an example using a dataset called "mydata" with two categorical variables, "factor1" and "factor2", and a continuous response variable, "response":
main.r79 chars3 lines
In this case, we are specifying a full factorial model with an interaction term between the two factors (specified using the * symbol). You can also run a main effects-only model by removing the interaction term. The summary()
function will output the ANOVA table, which includes F-statistics, p-values, and other relevant information.
gistlibby LogSnag