Possible Duplicate:
how to pivot/unpivot (cast/melt) data frame?
I have this data frame
idx A B C D
1 12 23 33 4
2 33 22 23 6
which I would like to convert to the following format (which ggplot2
seems to prefer)
idx col value
1 A 12
1 B 23
1 C 33
1 D 4
2 A 33
2 B 22
2 C 23
2 D 6
Is there any way to do it with standard R code (or a ggplot2
function that I am missing)?