test_that("Basic form check", {
df = structure(list(x1 = c(3L, 3L, 10L, 6L, 2L, 5L, 5L, 4L, 8L, 3L,
5L, 6L, 1L, 1L, 9L, 3L, 3L, 7L, 4L, 6L, 6L, 2L, 10L, 9L, 9L,
10L, 8L, 1L, 4L, 2L, 3L, 10L, 2L, 7L, 4L, 5L, 10L, 2L, 5L, 8L,
7L, 3L, 6L, 5L, 6L, 4L, 4L, 9L, 8L, 4L, 8L, 8L, 2L, 5L, 4L, 2L,
6L, 5L, 10L, 8L, 10L, 6L, 7L, 9L, 2L, 4L, 9L, 10L, 8L, 6L, 3L,
5L, 6L, 9L, 9L, 1L, 10L, 9L, 3L, 1L, 4L, 10L, 10L, 3L, 10L, 7L,
3L, 10L, 3L, 8L, 2L, 5L, 7L, 5L, 9L, 9L, 10L, 9L, 5L, 4L),
x2 = structure(c(18378.4374374374,
18579.5205205205, 18275.9089089089, 18273.1271271271, 18382.8088088088,
18378.8348348348, 18326.7757757758, 18360.951951952, 18644.6936936937,
18476.5945945946, 18373.2712712713, 18558.0610610611, 18358.5675675676,
18630.3873873874, 18372.0790790791, 18292.5995995996, 18534.2172172172,
18356.5805805806, 18404.2682682683, 18313.6616616617, 18364.1311311311,
18616.0810810811, 18622.4394394394, 18595.4164164164, 18551.3053053053,
18340.6846846847, 18512.3603603604, 18647.0780780781, 18400.6916916917,
18619.2602602603, 18568.7907907908, 18585.8788788789, 18310.8798798799,
18614.0940940941, 18315.2512512513, 18504.8098098098, 18342.2742742743,
18531.4354354354, 18397.1151151151, 18411.024024024, 18396.3203203203,
18514.7447447447, 18446.7897897898, 18560.048048048, 18444.4054054054,
18487.7217217217, 18478.5815815816, 18350.2222222222, 18428.9069069069,
18370.8868868869, 18371.2842842843, 18482.5555555556, 18511.1681681682,
18292.2022022022, 18457.1221221221, 18381.2192192192, 18636.7457457457,
18383.6036036036, 18268.3583583584, 18642.7067067067, 18587.4684684685,
18559.2532532533, 18290.6126126126, 18602.5695695696, 18612.9019019019,
18351.8118118118, 18373.2712712713, 18453.1481481481, 18655.8208208208,
18416.5875875876, 18319.2252252252, 18646.2832832833, 18337.9029029029,
18614.4914914915, 18431.6886886887, 18574.3543543544, 18544.5495495495,
18651.8468468468, 18436.0600600601, 18331.5445445445, 18629.98998999,
18548.5235235235, 18445.2002002002, 18569.982982983, 18564.8168168168,
18495.2722722723, 18451.1611611612, 18455.9299299299, 18585.0840840841,
18480.965965966, 18604.1591591592, 18286.2412412412, 18287.4334334334,
18594.2242242242, 18613.6966966967, 18361.3493493493, 18571.5725725726,
18430.4964964965, 18618.4654654655, 18291.8048048048), class = "Date")),
class = "data.frame", row.names = c(NA,
-100L))
df_cohort = cohort_count(df, x1, x2, "month", relative_time = FALSE)
df_cohort2 = cohort_count(df, x1, x2, "month", all_group = TRUE)
expect_match(names(df_cohort2)[-1],"(week|month|year)_[0-9]+")
expect_snapshot(as.list(df_cohort))
expect_snapshot(as.list(df_cohort2))
})
test_that("Test accuracy",{
dfx = data.frame(
x1 = c(1,1,1,2,2,2,3,3),
x2 = as.Date(c("2020-01-01", "2020-02-01", "2020-2-01", "2020-01-01", "2020-03-01", "2020-03-01", "2020-03-01", "2020-03-01"))
)
df_cohort = cohort_count(dfx, x1,x2, "month")
expect_snapshot(as.list(df_cohort))
})
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.