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 1 S1 s 4 Me F 1 2 S1 s 3 Me F 2 3 S1 s 5 Me J 1 4 S1 s 6 Me J 2 5 S1 s 6 She F 1 6 S1 s 6 She F 2 7 S1 s 10 She J 1 8 S1 s 9 She J 2 On Fri, Oct 7, 2011 at 7:16 AM, Jim Lemon <j...@bitwrit.com.au> wrote: > 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 (2 levels: Me / She) >> 4) F: within-subject factor (2 levels: F1 / F2) >> 5) J: within-subject factor (2 levels: J1 / J2) > > Hi Gang, > I don't know whether this is the format you want, but: > > library(prettyR) > rep_n_stack(mydata,matrix(c(2,3,6,7,4,5,8,9),nrow=2,byrow=TRUE)) > > Jim > ______________________________________________ R-help@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.