splitapply help with logicals
古いコメントを表示
Hello!
I need some help from this. Again, after thinking, I came up with a table like this.
Yes/No Genders
___________ __________
Yes female
No male
No they
Yes female
yes male
So I guess the question here would be "Have you ever identified yourself as any of these genders at any given time?"
And given the data I want my output to be like this:
Yes/No Female Male They
___________ _______ _____ _____
Yes 16 13 33
No 20 22 7
So basically the genders theyve identifed as would be turned into their own columns.
I was inspired by these mathworks pages:
So these are my thoughts so far:
- the Yes/No would be logical since they're esstienally true/false
- of course split apply would be used here.
- I was also thinking I could use @sum to find the sum of yes and no of the Genders instead of making my own functions since I am not confident in that yet
So what should be my first steps? Here is an idea I have:
MaleT= nnz(ismember(T2.genders(T2.response == true), 'male'))
FemaleF = nnz(ismember(T2.genders(T2.response == false), 'female'))
% repeat above for each true and false of the genders
Not sure what next steps to take from here...
採用された回答
その他の回答 (0 件)
カテゴリ
ヘルプ センター および File Exchange で Tables についてさらに検索
製品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!