Preprocessing: excel table headers into categoricals
1 次查看(过去 30 天)
显示 更早的评论
I recieve test data in a 'nice to look at' format in an excel file as below. The test setups are divided as headers over two rows.
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/314114/image.png)
I would like to do statistical comparisons of the values based on the different setups as categories, eg H values vs V values or the different positions RU vs LT for example. This would however require the data to be at the following format.
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/314117/image.png)
Is there a way to re-arrange the data from the first table with headers to a table where all values are stacked and the categoires in their own columns in a fairly easy way without using copy paste in excel prior to import?
I currently have the data imported to a table in matlab similar to the first format but the headers are only called pos_1, pos_2 etc so the directional and position information is not included.
BR, Emelie
0 个评论
回答(1 个)
Eric Sofen
2020-6-26
stack is the function that does the operation that converts a "wide" table with separate variables to a "tall" table with an indicator variable. Because of the two levels of hierarchy (LT/RT/LU/RU and H/V), you'll need to call stack multiple times and then vertically concatenate the results together.
Hope that helps gets you started.
0 个评论
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!