Here's a way to do it using reshape2
. The trick is to get the data into long format first.
library(reshape2)
d <- data.frame(var=c("Mean", "Median"),
Year=sort(rep(2006:2008,2)),
A=1:6, B=11:16)
d_melted <- melt(d, measure.vars=c("A", "B"))
dcast(d_melted, variable + Year ~ var)