@@ -32,23 +32,19 @@ test_that("epi_keys_mold extracts time_value and geo_value, but not raw",{
32
32
})
33
33
34
34
test_that(" epi_keys_mold extracts additional keys when they are present" , {
35
- my_data <- tibble :: tibble(
36
- geo_value = rep(c(" ca" , " fl" , " pa" ), each = 3 ),
37
- time_value = rep(seq(as.Date(" 2020-06-01" ), as.Date(" 2020-06-03" ),
38
- by = " day" ), length.out = length(geo_value )),
39
- pol = rep(c(" blue" , " swing" , " swing" ), each = 3 ), # extra key
40
- state = rep(c(" ca" , " fl" , " pa" ), each = 3 ), # extra key
41
- value = 1 : length(geo_value ) + 0.01 * rnorm(length(geo_value ))
42
- ) %> %
43
- epiprocess :: as_epi_df(additional_metadata = list (other_keys = c(" state" , " pol" )))
44
-
35
+ my_data <- case_death_rate_subset %> %
36
+ sample_n(6 ) %> %
37
+ tsibble :: as_tsibble() %> % # add 2 extra keys
38
+ mutate(state = rep(" MA" , 6 ), pol = rep(" blue" , 6 )) %> %
39
+ as_epi_df(additional_metadata = list (other_keys = c(" state" , " pol" )))
40
+
45
41
my_recipe <- epi_recipe(my_data ) %> %
46
- step_epi_ahead(value , ahead = 7 ) %> %
42
+ step_epi_ahead(death_rate , ahead = 7 ) %> %
47
43
step_epi_naomit()
48
44
49
45
my_workflow <- epi_workflow(my_recipe , linear_reg()) %> % fit(my_data )
50
46
51
- expect_setequal (
52
- epi_keys_mold(my_workflow $ pre $ mold ),
47
+ expect_equal (
48
+ epi_keys_mold(my_workflow $ pre $ mold ),
53
49
c(" time_value" , " geo_value" , " state" , " pol" ))
54
50
})
0 commit comments