Suppose (to simplify) I have a table containing some control vs. treatment data:
Which, Color, Response, Count Control, Red, 2, 10 Control, Blue, 3, 20 Treatment
Using the reshape package.
First, melt your data.frame:
x <- melt(df)
Then cast:
dcast(x, Color ~ Which + variable)
Depending on which version of the reshape package you're working with it could be cast() (reshape) or dcast() (reshape2)
cast()
dcast()
Voila.