@@ -25,33 +25,21 @@ test_that("Warning against max_version being same as edf's max version",{
25
25
test_that(" as_of properly grabs the data" ,{
26
26
d <- as.Date(" 2020-06-01" )
27
27
28
- generate_time_values <- function () {
29
- x <- c()
30
- for (i in 0 : 3 ) {
31
- x <- c(rep(d + i ,4 ),x )
32
- }
33
- return (rev(x ))
34
- }
35
-
36
- generate_versions <- function () {
37
- x <- c()
38
- for (i in 0 : 3 ) {
39
- x <- c(d + i ,x )
40
- }
41
- x <- rep(x ,4 )
42
- return (rev(x ))
43
- }
44
-
45
- ea2 <- tibble(
46
- geo_value = " ca" ,
47
- time_value = generate_time_values(),
48
- version = generate_versions()
49
- ) %> %
50
- filter(version > = time_value )
51
-
52
- ea2 <- ea2 [- c(9 ,4 ,3 ),]
53
- ea2 <- bind_cols(ea2 ,cases = c(1 ,2 ,0 ,1 ,2 ,1 ,4 ))
54
- ea2 <- as_epi_archive(ea2 )
28
+ ea2 = tibble :: tribble(
29
+ ~ geo_value , ~ time_value , ~ version , ~ cases ,
30
+ " ca" , " 2020-06-01" , " 2020-06-01" , 1 ,
31
+ " ca" , " 2020-06-01" , " 2020-06-02" , 2 ,
32
+ #
33
+ " ca" , " 2020-06-02" , " 2020-06-02" , 0 ,
34
+ " ca" , " 2020-06-02" , " 2020-06-03" , 1 ,
35
+ " ca" , " 2020-06-02" , " 2020-06-04" , 2 ,
36
+ #
37
+ " ca" , " 2020-06-03" , " 2020-06-03" , 1 ,
38
+ #
39
+ " ca" , " 2020-06-04" , " 2020-06-04" , 4 ,
40
+ ) %> %
41
+ dplyr :: mutate(dplyr :: across(c(time_value , version ), as.Date )) %> %
42
+ as_epi_archive()
55
43
56
44
df_as_of <- ea2 %> %
57
45
epix_as_of(max_version = as.Date(" 2020-06-03" )) %> %
0 commit comments