私はそのようなデータフレームを持っています:
a1 a2 a3 a4 b c d1 d2 d3 d4
[1] 0 0 1 0 0 0 0 1 0 0
[2] 0 1 0 0 1 0 0 1 0 0
...
私はそれを以下のように変換したいと思います、私はここで形を変えることは役に立たないと思います、行くための最良の方法は何でしょうか?
a b c d
[1] 0 0 0 0 # a and d as a1 and d1 of first row
[2] 0 0 0 1 # a and d as a2 and d2 of first row
[3] 1 0 0 0 # a and d as a3 and d3 of first row
[4] 0 0 0 0 # a and d as a4 and d4 of first row
[5] 0 1 0 0 # a and d as a1 and d1 of second row
[6] 1 1 0 1 # a and d as a2 and d2 of second row
[7] 0 1 0 0 # a and d as a3 and d3 of second row
[8] 0 1 0 0 # a and d as a4 and d4 of second row
...
ありがとうございました。