Applying a function to groups when missing values
Info
This question is closed. Reopen it to edit or answer.
Show older comments
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
Answers (1)
This question is closed.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!