@@ -22,52 +22,55 @@ row_replace <- function(dt,row,x,y) {
22
22
dt
23
23
}
24
24
25
+ # Note that compactify is working on version-wise LOCF (last version of each
26
+ # observation carried forward)
27
+
25
28
# Rows 1 should not be eliminated even if NA
26
- dt <- row_replace(dt ,1 ,NA ,NA ) # Not LVCF
29
+ dt <- row_replace(dt ,1 ,NA ,NA ) # Not LOCF
27
30
28
31
# NOTE! We are assuming that there are no NA's in geo_value, time_value,
29
32
# and version. Even though compactify may erroneously remove the first row
30
33
# if it has all NA's, we are not testing this behaviour for now as this dataset
31
34
# has problems beyond the scope of this test
32
35
33
36
# Rows 11 and 12 correspond to different time_values
34
- dt <- row_replace(dt ,12 ,11 ,11 ) # Not LVCF
37
+ dt <- row_replace(dt ,12 ,11 ,11 ) # Not LOCF
35
38
36
39
# Rows 20 and 21 only differ in version
37
- dt <- row_replace(dt ,21 ,20 ,20 ) # LVCF
40
+ dt <- row_replace(dt ,21 ,20 ,20 ) # LOCF
38
41
39
42
# Rows 21 and 22 only differ in version
40
- dt <- row_replace(dt ,22 ,20 ,20 ) # LVCF
43
+ dt <- row_replace(dt ,22 ,20 ,20 ) # LOCF
41
44
42
45
# Row 39 comprises the first NA's
43
- dt <- row_replace(dt ,39 ,NA ,NA ) # Not LVCF
46
+ dt <- row_replace(dt ,39 ,NA ,NA ) # Not LOCF
44
47
45
48
# Row 40 has two NA's, just like its lag, row 39
46
- dt <- row_replace(dt ,40 ,NA ,NA ) # LVCF
49
+ dt <- row_replace(dt ,40 ,NA ,NA ) # LOCF
47
50
48
51
# Row 62's values already exist in row 15, but row 15 is not a preceding row
49
- dt <- row_replace(dt ,62 ,15 ,15 ) # Not LVCF
52
+ dt <- row_replace(dt ,62 ,15 ,15 ) # Not LOCF
50
53
51
54
# Row 73 only has one value carried over
52
- dt <- row_replace(dt ,74 ,73 ,74 ) # Not LVCF
55
+ dt <- row_replace(dt ,74 ,73 ,74 ) # Not LOCF
53
56
54
57
dt_true <- as_tibble(as_epi_archive(dt ,compactify = TRUE )$ DT )
55
58
dt_false <- as_tibble(as_epi_archive(dt ,compactify = FALSE )$ DT )
56
59
dt_null <- suppressWarnings(as_tibble(as_epi_archive(dt ,compactify = NULL )$ DT ))
57
60
58
- test_that(" Warning for LVCF with compactify as NULL" , {
61
+ test_that(" Warning for LOCF with compactify as NULL" , {
59
62
expect_warning(as_epi_archive(dt ,compactify = NULL ))
60
63
})
61
64
62
- test_that(" No warning when there is no LVCF " , {
65
+ test_that(" No warning when there is no LOCF " , {
63
66
expect_warning(as_epi_archive(dt [1 : 5 ],compactify = NULL ),NA )
64
67
})
65
68
66
- test_that(" LVCF values are ignored with compactify=FALSE" , {
69
+ test_that(" LOCF values are ignored with compactify=FALSE" , {
67
70
expect_identical(nrow(dt ),nrow(dt_false ))
68
71
})
69
72
70
- test_that(" LVCF values are taken out with compactify=TRUE" , {
73
+ test_that(" LOCF values are taken out with compactify=TRUE" , {
71
74
dt_test <- as_tibble(as_epi_archive(dt [- c(21 ,22 ,40 ),],compactify = FALSE )$ DT )
72
75
73
76
expect_identical(dt_true ,dt_null )
@@ -78,7 +81,7 @@ test_that("as_of produces the same results with compactify=TRUE as with compacti
78
81
ea_true <- as_epi_archive(dt ,compactify = TRUE )
79
82
ea_false <- as_epi_archive(dt ,compactify = FALSE )
80
83
81
- # Row 22, an LVCF row corresponding to the latest version, is omitted in
84
+ # Row 22, an LOCF row corresponding to the latest version, is omitted in
82
85
# ea_true
83
86
latest_version = max(ea_false $ DT $ version )
84
87
expect_warning({
0 commit comments