0

I'm usually doing this rearrange with SPSS (varstocases function) and wanted to know if there is something similar in R with tidyverse (not R base).

Brand 1 2 3
1     1 1 0
2     2 1 0
3     0 1 1  
4     0 0 0
5     1 0 0

I would like to create to columns Var1 and Var2 such that I get a restructure of the data like this:

Brand Var1 Var2
1     1    1 
1     2    1   
1     3    0
2     1    2  
2     2    1
2     3    0
3     1    0
3     2    0
3     3    1
4     1    0
4     2    0
4     3    0
5     1    1
5     2    0
5     3    0

Regards!

Konrad Rudolph
  • 506,650
  • 124
  • 909
  • 1,183
EGM8686
  • 1,388
  • 1
  • 10
  • 17

0 Answers0