0

This I am certain is a duplicate question. Pardon me for this violation. I have a dataset like this in a long format.

   ID TIME  Col1   Value 
   A    1   X1     25
   B    1   X1     26
   C    1   X2     27
   A    2   X1     28
   A    2   X2     29
   C    2   X1     30
   D    1   X1     31
   D    1   X2     32
   C    3   X2     33
  

What I am trying to do is convert this to a wide format like this

  ID TIME   X1  X2
  A  1      25  
  B  1      26  
  C  1          27
  A  2      28  29
  C  2      30  
  D  1      31  32
  C  3          33 

I tried df1 %>% spread(Col1, Value) and this did not work. Any help on transforming this to wide format is much apricated. Thanks in advance.

0 Answers0