[R] Could anyone help me reshape this "wide" data into	"longitudinal" one? Thanks
    Frank Duan 
    fhduan at gmail.com
       
    Mon Nov 29 00:13:20 CET 2004
    
    
  
Dear R people,
I have a matrix like this:
      var1   var2    var3    var4 
a1   7.1   7.2       8.1    8.2 
a2  10.5  10.6    ...       ...
a3
b1
b2
b3
b4
c1
c2
...
The matrix row names are "a1", "a2", ......  and the matrix column
names are "var1", "var2", "var3" and "var4". Now I want to reshape
this data into a longitudinal-formatted one like this:
subject    seq   time    resp        
a              1      1        7.1
a              1      2        7.2
a              1      3        8.1
a              1      4        8.2
a              2      1       10.5 
a              2      2       10.6
a              2      3         ...
a              2      4         ...
a              3      1         ...
a              3      2
a              3      3
a              3      4
b              1      1
b              1      2
b              1      3
b              1      4
b              2      1
b              2      2
b              2      3
b              2      4
...             ...    ...
...             ...    ...
...             ...    ...
I always met errors when using "reshape" function. Could anyone give
me an idea how to do it?
Many thanks to you,
Frank
    
    
More information about the R-help
mailing list