Transform data from long to wide format
13 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
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 Kommentare
Antworten (1)
Star Strider
am 12 Jul. 2022
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 Kommentare
Star Strider
am 13 Jul. 2022
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.
Siehe auch
Kategorien
Mehr zu Data Type Identification finden Sie in Help Center und File Exchange
Produkte
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!