calculate average only for one group

조회 수: 2 (최근 30일)
alpedhuez
alpedhuez 2020년 7월 6일
답변: Image Analyst 2020년 7월 6일
I have a table T
YYYY Name Location Income
-----------------
2020 A E 300K
2020 B W 250K
2020 C E 400K
2020 D W 300K
Then I want to take an average of income only for people at West Coast.
unstack{T,'income','location','Grouping Variables','YYYY','AggregationFunction', @mean)
will provide average income for both NY and SF. But I just want to calcuate mean for NY.

답변 (2개)

alpedhuez
alpedhuez 2020년 7월 6일

Image Analyst
Image Analyst 2020년 7월 6일
Try the built-in functions grpstats() or splitapply(). Attach code to make your table if you need more help.

카테고리

Help CenterFile Exchange에서 Whos에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by