I have a very simple data count problem where I am grouping by two fields (MktDate,Indexname) which are date and chr types respectively. I have a few indexes with no data on certain dates and all I'm looking for my code to do is to include a 0 on those dates. I have tried a number of different solutions following dplyr's group_by documentation but I can not get this short piece of code to return a value of 0 when no data is present. Here is my code
IdxStats <- IdxData %>%
group_by(MktDate,IndexName,.drop=FALSE) %>%
summarize(CountSecurity = length(MktDate)) %>%
ungroup