test_that("complete_dates works", { dat <- data.frame( dates = Sys.Date() + 1:4, groups1 = rep(c("bob","george"), 2), groups2 = c(rep("groupa", 2), rep("groupb", 2)), counts1 = 1:4, counts2 = 11:14 ) i <- incidence( dat, date_index = "dates", groups = c("groups1", "groups2"), counts = c("counts1", "counts2") ) res <- complete_dates(i, fill = NA) expect_identical(nrow(res), 32L) tmp <- res[complete.cases(res),] row.names(tmp) <- NULL expect_identical(tmp, i) res2 <- complete_dates(i) expect_identical( tapply(res2$count, res2$count_variable, sum), tapply(i$count, i$count_variable, sum) ) expect_identical(nrow(res2), 32L) expect_identical( incidence( dat, date_index = "dates", groups = c("groups1", "groups2"), counts = c("counts1", "counts2"), complete_dates = TRUE ), res2 ) })