calculate average only for one group
2 ビュー (過去 30 日間)
古いコメントを表示
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.
0 件のコメント
回答 (2 件)
Image Analyst
2020 年 7 月 6 日
Try the built-in functions grpstats() or splitapply(). Attach code to make your table if you need more help.
0 件のコメント
参考
カテゴリ
Help Center および File Exchange で Workspace Variables and MAT-Files についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!