proportion of gender having health issue
Mostra commenti meno recenti
I have a table that has Gender vector (1=Boy, 2=Girl) and Healtissue (based on score). I would like to know the proportion of girls only have a health issue if their score more than 17?
2 Commenti
dpb
il 31 Mag 2020
Look at findgroups, groupsummary with the Subject "Split-Apply-Combine" workflow under splitapply
Many examples...
Doaa Alamoudi
il 31 Mag 2020
Risposta accettata
Più risposte (1)
dpb
il 31 Mag 2020
Some other things to explore...
hScore=randi(100,100,1)/4; % An artificial dataset...
sex=(rand(size(hScore))>0.5)+1; % 50:50 roughly
tMH=table(sex,hScore,'VariableNames',{'Gender','HealthIssue'}); % make a table
tMH.Gender=categorical(tMH.Gender,[1,2],{'Boy','Girl'}); % turn into categorical instead
tMH.AtRisk=categorical(tMH.HealthIssue>17); % compute the risk factor
heatmap(tMH,'Sex','AtRisk') % one way to look at results...
Results will vary for a random sample, but for the particular dataset generated here:
>> groupsummary(tMH,'Gender')
ans =
2×2 table
Gender GroupCount
______ __________
Boy 51
Girl 49
>> groupsummary(tMH,'AtRisk')
ans =
2×2 table
AtRisk GroupCount
______ __________
false 68
true 32
>> groupsummary(tMH,{'Gender','AtRisk'})
ans =
4×3 table
Gender AtRisk GroupCount
______ ______ __________
Boy false 37
Boy true 14
Girl false 31
Girl true 18
>>
You can compute percentages from the GroupCounts depending upon whether want by Gender or overall...the above produces

1 Commento
Doaa Alamoudi
il 31 Mag 2020
Categorie
Scopri di più su Logical in Centro assistenza e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!