@@ -32,19 +32,23 @@ 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 <- 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
-
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
+
41
45
my_recipe <- epi_recipe(my_data ) %> %
42
- step_epi_ahead(death_rate , ahead = 7 ) %> %
46
+ step_epi_ahead(value , ahead = 7 ) %> %
43
47
step_epi_naomit()
44
48
45
49
my_workflow <- epi_workflow(my_recipe , linear_reg()) %> % fit(my_data )
46
50
47
- expect_equal (
48
- epi_keys_mold(my_workflow $ pre $ mold ),
51
+ expect_setequal (
52
+ epi_keys_mold(my_workflow $ pre $ mold ),
49
53
c(" time_value" , " geo_value" , " state" , " pol" ))
50
54
})
0 commit comments