Transform data from long to wide format
10 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
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 Commenti
Risposte (1)
Star Strider
il 12 Lug 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 Commenti
Star Strider
il 13 Lug 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.
Vedere anche
Categorie
Scopri di più su Data Type Identification in Help Center e File Exchange
Prodotti
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!