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...

 採用された回答

Adam Danz
Adam Danz 2020 年 9 月 1 日
編集済み: Adam Danz 2020 年 9 月 1 日

0 投票

groupsummary() does that but in a different format.
Demo
T = table(categorical({'Y';'N';'N';'Y';'Y'}),...
categorical({'F';'M';'T';'F';'M'}), 'variablenames', {'YN','Gender'})
% T =
% 5×2 table
% YN Gender
% __ ______
% Y F
% N M
% N T
% Y F
% Y M
GS = groupsummary(T,{'YN','Gender'})
% GS =
% 4×3 table
% YN Gender GroupCount
% __ ______ __________
% N M 1
% N T 1
% Y F 2
% Y M 1
Number of "yes" answers associated with "female":
GS.GroupCount(GS.YN=='Y' & GS.Gender=='F')
% ans =
% 2

1 件のコメント

Karen Landeros
Karen Landeros 2020 年 9 月 2 日
Oh, okay this will be useful. Thank you so much :-D

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

ヘルプ センター および File ExchangeTables についてさらに検索

製品

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by