I have what should be a simple reshaping problem, but I can\'t figure it out. Part of my data looks like this:
foo <- structure(list(grade = c(3, 3, 4, 4,
library(plyr)
library(reshape2)
# First we add a grouping variable to deal with the duplicates
foo <- ddply(foo, .(grade, var.type), function(x) { x$group <- 1:nrow(x); x })
dcast(foo, grade + group ~ var.type, value.var= "var.val")[-2]
grade SE SS
1 3 47 120
2 3 12 120
3 4 46 120
4 4 14 120
5 5 46 120
6 5 16 120
7 6 47 120
8 6 20 120
9 7 46 120
10 8 46 120