0
您好我一直在試圖將我的數據重新整形。通過每個ID中的唯一值重塑變量
id story_id
1 123
1 123
1 123
1 123
2 213
2 213
2 213
3 123
3 123
3 123
但我得到的是:
id
1
2
3
我使用的代碼:
data=reshape(data, idvar="id", timevar="story_id", direction="wide")
所需的輸出是
id story_id.123 story_id.213
1 123 NA
2 NA 213
3 123 NA
請讓我知道什麼問題是。
我已經更新了我的問題@MrFlick –
不會'表(唯一的(數據))'是更理想的選擇? 'reshape(unique(data)[,c(1,2,2)],timevar ='story_id.1',v.names ='story_id',dir ='wide')'也可以工作 – rawr
@rawr -you can (變換(唯一(數據),時間= story_id),idvar =「id」,方向=「寬」)。 – thelatemail