Mean for certain conditions
1 回表示 (過去 30 日間)
古いコメントを表示
Hello,
I hope I can express my problem right, if not please ask about further details.
I am quite the beginner so I already have problems 'translating' the following basics into matlab language:
I have a table with data of a rating experiment and I need to get the mean values of certain items.
For each ID (all the '2' lines are one subject) I need a mean for the four ratings of the four phases of each snack and item. For example, I want the mean of the ratings of phases 1-4 for the item 'wanting' for the snack 'Gummibärchen', and that for each subject. ANd that for all items and snacks.
The plan after that is to visualise those differnces in heatmaps or plots but I am not sure how my desired output should look like (e.g. list or table or?). If you have tips regarding this, that would be great, too.
I have included a table with the data of 2 test IDs for testing, if that helps.
(Because the table is quite long, this screenshot only shows the beginnign of the table but as you can see the first 8 lines are all the 'Gummibärchen' ratings for phase 1 with the 8 rating-items. After that follows the same for 'Crackers', etc. Then, after the 6 snacks it switches back to 'Gummibärchen' and starts phase 2...)
Thank you for your help!
0 件のコメント
採用された回答
Ive J
2021 年 2 月 7 日
編集済み: Ive J
2021 年 2 月 7 日
t = readtable('extracted_table.xlsx');
y = groupsummary(t, {'ID', 'Item', 'Snack'}, @mean, 'Rating'); % mean of Rating for each ID, Item and Snack combination
head(y)
ID Item Snack GroupCount fun1_Rating
__ ______________ _________________ __________ ___________
2 {'Bitternis' } {'Brezeln' } 4 1.5367
2 {'Bitternis' } {'Cracker' } 4 0.44025
2 {'Bitternis' } {'Gummibaerchen'} 4 3.4337
2 {'Bitternis' } {'Kekse' } 4 0.28776
2 {'Bitternis' } {'Nic Nacs' } 4 1.8572
2 {'Bitternis' } {'Rosinen' } 4 5.322
2 {'Intensität'} {'Brezeln' } 4 52.593
2 {'Intensität'} {'Cracker' } 4 32.14
You can visualize it also with scatter3
scatter3(categorical(y.Item), categorical(y.Snack), y.fun1_Rating, 50, y.ID, 'filled')
c = colorbar(gca);
c.Ticks = unique(y.ID);
c.TickLabels = string(unique(y.ID)); % show IDs on the colorbar
その他の回答 (0 件)
参考
カテゴリ
Help Center および File Exchange で Data Distribution Plots についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!