[R] Convert dataframe with two factors from wide to long format

From: Gang Chen <gangchen6_at_gmail.com>
Date: Sun, 22 May 2011 17:25:43 -0400


I know how to convert a simple dataframe from wide to long format with one varying factor. However, for a dataset with two factors like the following,

Subj T1_Cond1 T1_Cond2 T2_Cond1 T2_Cond2  1 0.125869 4.108232 1.099392 5.556614  2 1.427940 2.170026 0.120748 1.176353

How to elegantly convert to a long form as

Subj Time Cond Value

1         1        1       0.125869
1         1        2       4.108232
1         2        1       1.099392

...

Thanks in advance!

Gang

        [[alternative HTML version deleted]]



R-help_at_r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. Received on Sun 22 May 2011 - 21:30:18 GMT

This quarter's messages: by month, or sorted: [ by date ] [ by thread ] [ by subject ] [ by author ]

All messages

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Sun 22 May 2011 - 23:30:09 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.

list of date sections of archive