我的数据如下所示:
fruit ID
apple 1
mango 1
orange 1
grapes 2
strawberries 3
我想使用 reshape 做的是以下内容:
ID Fruit
1 apple,mango,orange
2 grapes
3 strawberries
我试过重塑
rehshape(data=test,direction="long",varying=c(1,2),v.names="v1",timevar="v2",times=c(1,2))->test.long
但这显然是错误的。