There is a good example you can follow here. Take special note of the details given in the "Prepare Data for Balanced Two-Way ANOVA" section.
- To perform balanced two-way ANOVA using anova2, you must arrange data in a specific matrix form. The columns of the matrix must correspond to groups of the column factor, B. The rows must correspond to the groups of the row factor, A, with the same number of replications for each combination of the groups of factors A and B.