Transform data from long to wide format
14 ビュー (過去 30 日間)
古いコメントを表示
Hi community,
My data is currently in long format (data_long.csv) and I am trying to convert it to wide format (data_wide.csv).
I have 15 participants and 16 variables to do this for. Any tips would be great!
Thank you,
Danielle
0 件のコメント
回答 (1 件)
Star Strider
2022 年 7 月 12 日
Use unstack, preferably the same unstack call with the same MATLAB version that produced the ‘data_wide’ file.
Experiment with it, since I cannot get the same result.
L1 = readtable('https://www.mathworks.com/matlabcentral/answers/uploaded_files/1062580/data_long.csv')
W1 = readtable('https://www.mathworks.com/matlabcentral/answers/uploaded_files/1062585/data_wide.csv')
L1toW2 = unstack(L1,{'Var1','Time'},'Con')
.
2 件のコメント
Star Strider
2022 年 7 月 13 日
It depends on wthe result you want. I used two grouping variables and it seemed to work (R2022a). The result provided seems to have changed over the last few versions. You will likely have to experiment with it.
参考
カテゴリ
Help Center および File Exchange で Data Type Identification についてさらに検索
製品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!