0

I want to reshape this table:

data<-read.table(header=T, text=c("

X T V W  
0 a g m  
0 b h n  
0 c i o  
1 d j p  
1 e k q  
1 f l r "))  

To

X T1 T2 T3 V1 V2 V3 W1 W2 W3  
0 a  b  c  g  h  i  m  n  o  
1 d  e  f  j  k  l  p  q  r  

So we take only the first observations of each group in X and transpose corresponding values in T, V and W into columns.
Note that I have almost 2000 groups of repeated values in X (000, 111, 222, ... ) and I need to know how to reshape it with R. It means I start with 6000 rows to obtain after reshaping 2000 rows but the remaing 2 values of each group in T, V and W have to be transposed in new columns T2, T3, etc. Thanks!

Houssem
  • 143
  • 9
  • fix the code by adding an `)` at the end of your data. – SabDeM Jul 13 '15 at 16:30
  • 1
    It is different and I explained how it is different. The answer you gave is for another example where all rows have been transposed into columns and this is NOT the case of my example. In my question redundant values in the first column have to be deleted and ONLY correspondant values in the others columns have to be transposed. This is TOTALLY different. – Houssem Jul 13 '15 at 18:22
  • I agree with the OP. – SabDeM Jul 13 '15 at 19:55

0 Answers0