How do I organize a table using a specified cell array?

In the example found in this documentation, how would I index the data by Gender? Such as if I wanted a new table selecting only rows with {'Male' } or {'Female'}?
I am wondering if it is different than:
rows = (T.Smoker==true & T.Age<40);
T(rows,:)
as it is a cell. Thank you.

 채택된 답변

Star Strider
Star Strider 2020년 11월 12일
One approach is to use the findgroups function:
load patients
T = table(Age,Gender,Height,Weight,Smoker,...
'RowNames',LastName);
[Grp,ID] = findgroups(T.Gender);
Males = T(Grp==2,:);
The ‘ID’ variable indicates that these are sorted lexiically, so 1=Female, and 2=Male.

추가 답변 (0개)

카테고리

도움말 센터File Exchange에서 Tables에 대해 자세히 알아보기

제품

릴리스

R2020a

태그

질문:

2020년 11월 12일

댓글:

2020년 11월 12일

Community Treasure Hunt

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

Start Hunting!

Translated by