[R] melting a data frame
Data Analytics Corp.
walt at dataanalyticscorp.com
Sun Sep 8 05:33:09 CEST 2013
Hi,
Suppose I have a data frame with 189 columns. The columns are actually
9 blocks of 21 columns each, each block representing measures on each of
9 products. There are 130 rows. Suppose I extract the first block of
21 columns and make them into a separate data frame. I then want to
take the second block of 21 columns and rbind it to the first; then the
third set of 21 and rbind it to the first two; etc. The final data
frame should have 1170 (= 9 * 130) rows and 21 columns. Is there an
easy way to melt the blocks comparable to using the melt function in the
plyr package (which is why I'm referring to what I want to do as
"melting")? It seems that there should be a simple way to do this. I
used a for loop which worked, but I want to see if there's a more
efficient way.
Thanks,
Walt
________________________
Walter R. Paczkowski, Ph.D.
Data Analytics Corp.
44 Hamilton Lane
Plainsboro, NJ 08536
________________________
(V) 609-936-8999
(F) 609-936-3733
walt at dataanalyticscorp.com
www.dataanalyticscorp.com
More information about the R-help
mailing list