Whats the difference between a one way anova and two way anova? I know that in one way anova you compare the difference between two or more  means and the same in two way, but I'm unclear as to how the use of categorical variables differs between them.
Any help would be appreciated
 A: One-way ANOVA. There are two variables, one categorical and the other numerical.
The categorical variable might specify three treatment groups and the numerical variable a measurement on each subject or experimental unit.
Example:  The treatments might be 1=Drug 1, 2=Drug 2, and 3=Placebo. If there were 100 subjects in group (300 altogether) then the categorical variable would have
a hundred 1's, followed by a hundred 2's followed by a hundred 3's. The numerical variable might be the level of a liver enzyme for each of the 300 subjects.
The issue to be decided is whether the $g$ levels of the factor are the same
(have a common population mean) or whether their population means differ.
For human consumption the data might be given in three columns of 100 numbers each, with a group mean and standard deviation at the bottom of each column.
In an unbalanced design the groups can have different numbers of observations.
Perhaps the drug study above was planned to have 100 people in each group, but
several people dropped out of the study so we have $n_1 = 99$, $n_2 = 100$, and $n_3 = 94$. 
A one-way ANOVA model, which can have $g > 2$ groups, is a generalization of the two-sample t-test, which always has $g = 2$ groups.
An ANOVA table will have two rows, one for Drug (or Factor of Between Groups) and one for Error (or Within Groups). In a balanced design with $g = 3$ and $n_1 = n_2 = n_3 = n = 100,$ the degrees of freedom are as follows: DF(Drug) = $g - 1 = 2$ and DF(Error) = $g(n - 1) = 3(99)  = 279.$ If a Total row is provided, it has DF(Total) = $gn - 1,$ which is one less than the total number of numerical measurements.
The model for a one-way ANOVA design is $Y_{ij} = \mu_i + e_{ij},$ where
$i = 1,\dots,g$ and $j = i,\dots,n_i$. In a traditional ANOVA model
random variation is modeled as $e_{ij}$  IID $N(0, \sigma^2).$ That is
the population variance $\sigma ^2$ is assumed equal in all $g$ groups.
Block design. There are two categorical variables (factors) and a numerical variable. Only one observation is taken at each combination of factors.
Example: Four brands of burgundy wine (factor 1) are tasted by each of three
judges (factor 2). Each judge gives a quality rating to each brand, so that there are 12 ratings. 
A simple block design of this kind is a generalization of a paired t-test.
In a paired t-test only two brands of wine would be compared. Block is the generalization of pair. A block design is a special case of a two-way ANOVA design in which each combination of the factors (Brand and Judge) has only one observation.
For human consumption the data are typically displayed in a $b \times g$ matrix, where $b$ is the number of blocks (judges) and $g$ is the the number of levels of the 'main' factor (brands). Usually, the issue to be decided is whether the levels of the main factor have different population means, although one might secondarily be interested in whether some judges systematically give higher ratings than others. 
An ANOVA table for a block design will have three rows: In our example, they might be called Brand with DF = $g - 1$, Judge with DF = $b - 1$, and Error = $(b-1)(g-1).$ If a row for Total is shown, it will have DF = $bg - 1$, again one less than the total number of numerical measurements. 
The model for this block design is $Y_{ij} = \mu + \alpha_i + \beta_j + e_{ij},$ where $i = 1,\dots,g,$ and $j = 1,\dots,b.$ Traditionally, $e_{ij}$ IID $N(0, \sigma^2).$
Two-way ANOVA. Again here there are two categorical variables and one numerical variable. But there are several replications for each combination of factors. The issues are whether various levels of the factors have different population means. However, the multiple measurements at each combination of factor levels raises the possibility of testing for interaction.
Example: In an agricultural experiment we may have 12 plots on which a crop is grown. At the end of the growing season the yield of each plot is measured.
We are interested in three kinds of fertilizer and two levels of irrigation, making six treatment combinations. At random two plots are selected for each combination. Again there are three variables, two categorical (for Fertilizer and Irrigation) and one numerical (for Yield). 
For human consumption, data may be displayed in an $a \times b$ = $3 \times 2$ array of cells, each with $n = 2$ replications (Yields).
An interaction occurs if the yields in a cell cannot be explained in terms of a sum of the effects of Fertilizer and Irrigation. Perhaps one kind of fertilizer works particularly badly at low irrigation. 
The ANOVA table for such a design has four rows: Fertilizer with DF = $a - b$,
Irrigation with DF = $b - 1,$ Interaction with DF = $(a-1)(b-1),$,and Error
with DF = $ab(n-1).$ If a Total row is shown it has DF = $abn - 1,$ yet again one less than the total number of yields measured.
The model for a two-way ANOVA is $Y_{ijk} = \mu + \alpha_i + \beta_j + \gamma_{ij} + e_{ijk},$
where $i = 1,\dots,a,$ $j = 1,\dots,b,$ and $k=1,\dots,n.$ Again here, the traditional balanced design has $e_{ijk}$ IID $N(0, \sigma^2).$ 
Sometimes  unbalanced designs with unequal numbers of observations in each cell are considered, but they require somewhat different computational methods and interpretations. The two-way designs we have described here are ones with
fixed main effects that can be represented in the model by unknown, but constant parameters ($\alpha_i$ and $\beta_j$). we do not discuss so-called mixed or  random effects designs here, in which  one or both factors are represented in the model by random variables.
