Re: [R] Wide to long form conversion

2011-10-07 Thread Jim Lemon
On 10/07/2011 07:28 AM, Gang Chen wrote: I have some data 'myData' in wide form (attached at the end), and would like to convert it to long form. I wish to have five variables in the result: 1) Subj: factor 2) Group: between-subjects factor (2 levels: s / w) 3) Reference: within-subject factor

Re: [R] Wide to long form conversion

2011-10-07 Thread Gang Chen
Dennis, Yes, I was wrong! The variables should be: 1) Subj: factor 2) Group: between-subjects factor (2 levels: s / w) 3) Reference: within-subject factor (2 levels: Me / She) 4) F/J: within-subject factor (2 levels: F / J) 5) Time: within-subject factor (2 levels: 1 / 2) 6) Value So your

Re: [R] Wide to long form conversion

2011-10-07 Thread Gang Chen
Jim, I really appreciate your help! I like the power of rep_n_stack, but how can I use rep_n_stack to get the following result? Subj Group value Ref Var Time 1S1 s 4 Me F1 2S1 s 3 Me F2 3S1 s 5 Me J1 4S1 s 6 Me J2 5

Re: [R] Wide to long form conversion

2011-10-07 Thread David Winsemius
On Oct 7, 2011, at 7:40 AM, Gang Chen wrote: Jim, I really appreciate your help! I like the power of rep_n_stack, but how can I use rep_n_stack to get the following result? Subj Group value Ref Var Time 1S1 s 4 Me F1 2S1 s 3 Me F2 3S1 s 5

Re: [R] Wide to long form conversion

2011-10-07 Thread David Winsemius
On Oct 7, 2011, at 1:30 PM, David Winsemius wrote: On Oct 7, 2011, at 7:40 AM, Gang Chen wrote: Jim, I really appreciate your help! I like the power of rep_n_stack, but how can I use rep_n_stack to get the following result? Subj Group value Ref Var Time 1S1 s 4 Me F1 2

Re: [R] Wide to long form conversion

2011-10-07 Thread Gang Chen
David, thanks a lot for the code! I've learned quite a bit from all the generous help... Gang On Fri, Oct 7, 2011 at 1:37 PM, David Winsemius dwinsem...@comcast.net wrote: On Oct 7, 2011, at 1:30 PM, David Winsemius wrote: On Oct 7, 2011, at 7:40 AM, Gang Chen wrote: Jim, I really

[R] Wide to long form conversion

2011-10-06 Thread Gang Chen
I have some data 'myData' in wide form (attached at the end), and would like to convert it to long form. I wish to have five variables in the result: 1) Subj: factor 2) Group: between-subjects factor (2 levels: s / w) 3) Reference: within-subject factor (2 levels: Me / She) 4) F: within-subject

Re: [R] Wide to long form conversion

2011-10-06 Thread Andrew Miles
Take a look here. http://stackoverflow.com/questions/2185252/reshaping-data-frame-from-wide-to-long-format Andrew Miles Department of Sociology Duke University On Oct 6, 2011, at 4:28 PM, Gang Chen wrote: I have some data 'myData' in wide form (attached at the end), and would like to convert

Re: [R] Wide to long form conversion

2011-10-06 Thread Gang Chen
Thanks for the pointer! I still couldn't figure out how to convert my data because the example at stackoverflow seems to have only one variable (Year) while there are three within-subject variables plus one between-subjects variable. Any further help? Gang On Thu, Oct 6, 2011 at 4:34 PM, Andrew

Re: [R] Wide to long form conversion

2011-10-06 Thread Dennis Murphy
Hi: I have some data 'myData' in wide form (attached at the end), and would like to convert it to long form. I wish to have five variables in the result: 1) Subj: factor 2) Group: between-subjects factor (2 levels: s / w) 3) Reference: within-subject factor (2 levels: Me / She) 4) F: