I have added sample data below, I have used dplyr to count on Rco and month:
structure(list(Rco = structure(c(1L, 1L, 1L, 1L, 2L, 2
We can use expand.grid on the unique values of the first two columns, and merge with the initial dataset. This will fill NA for combinations that are not present in the expand.grid.
res <- merge(expand.grid(lapply(df1[1:2], unique)), df1, all.x=TRUE)
But, it is easy to change the NA to 0
res[is.na(res)] <- 0
You can use tidyr::complete and specify the fill to be 0 (instead of the default NA):
library(tidyr)
complete(df, Rco, month, fill = list(count = 0))