As mentioned by ran2, you can use the reshape package. Here is an example:
df <- data.frame(V1 = factor(sample(letters[1:5],100,replace=TRUE)),
V2 = factor(toupper(sample(letters[1:5],100,replace=TRUE))),
V3 = runif(100))
library(reshape)
cast(df, V1 ~ V2, mean)