Applying a function to groups when missing values
信息
此问题已关闭。 请重新打开它进行编辑或回答。
显示 更早的评论
Hi all, I have a huge table made in this way
ID1 ID2 Date Occurrences
1 1 2015-5 9
1 2 2015-5 11
1 2 2015-6 1
1 43 2015-8 2
2 3 2015-7 40
The primary key of the table is the triple (ID1,ID2,Date).
Now if I want to apply a function to sum how many occurrences a single ID1 has per month, getting rid of ID2, I can use:
varfun(@sum,data,'InputVariables','Occurrences', GroupingVariables',{'ID1','Date'});
is there a way to expand the grouping such that the dates considered are the all unique values in the Date column? In other words, the month 2015-7 is not present for ID1 = 1, but I would like to get a 0 instead of no row with that value because it is not present after grouping for ID1 = 1
0 个评论
回答(1 个)
此问题已关闭。
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!