我有长格式的数据,我试图重塑到宽,但似乎没有一个直接的方法来使用融化/堆栈/取消堆栈:
Salesman Height product price
Knut 6 bat 5
Knut 6 ball 1
Knut 6 wand 3
Steve 5 pen 2
Run Code Online (Sandbox Code Playgroud)
变为:
Salesman Height product_1 price_1 product_2 price_2 product_3 price_3
Knut 6 bat 5 ball 1 wand 3
Steve 5 pen 2 NA NA NA NA
Run Code Online (Sandbox Code Playgroud)
我认为Stata可以使用reshape命令执行类似的操作.