22
22
# ' being removed from the data. Alternatively, you could specify arbitrary
23
23
# ' large values, or perhaps zero. Setting this argument to `NULL` will result
24
24
# ' in no replacement.
25
- # ' @param additional_gr_args_list A list of additional arguments used by
26
- # ' [epiprocess::growth_rate()]. All `...` arguments may be passed here along
27
- # ' with `dup_rm` and `na_rm`.
25
+ # ' @inheritParams epiprocess::growth_rate
28
26
# ' @template step-return
29
27
# '
30
28
# '
@@ -46,11 +44,11 @@ step_growth_rate <-
46
44
horizon = 7 ,
47
45
method = c(" rel_change" , " linear_reg" ),
48
46
log_scale = FALSE ,
47
+ na_rm = TRUE ,
49
48
replace_Inf = NA ,
50
49
prefix = " gr_" ,
51
50
skip = FALSE ,
52
- id = rand_id(" growth_rate" ),
53
- additional_gr_args_list = list ()) {
51
+ id = rand_id(" growth_rate" )) {
54
52
if (! is_epi_recipe(recipe )) {
55
53
cli_abort(" This recipe step can only operate on an {.cls epi_recipe}." )
56
54
}
@@ -63,15 +61,7 @@ step_growth_rate <-
63
61
}
64
62
arg_is_chr(role )
65
63
arg_is_chr_scalar(prefix , id )
66
- arg_is_lgl_scalar(log_scale , skip )
67
-
68
-
69
- if (! is.list(additional_gr_args_list )) {
70
- cli_abort(c(
71
- " `additional_gr_args_list` must be a {.cls list}." ,
72
- i = " See `?epiprocess::growth_rate` for available options."
73
- ))
74
- }
64
+ arg_is_lgl_scalar(log_scale , skip , na_rm )
75
65
76
66
recipes :: add_step(
77
67
recipe ,
@@ -82,13 +72,13 @@ step_growth_rate <-
82
72
horizon = horizon ,
83
73
method = method ,
84
74
log_scale = log_scale ,
75
+ na_rm = na_rm ,
85
76
replace_Inf = replace_Inf ,
86
77
prefix = prefix ,
87
78
keys = key_colnames(recipe ),
88
79
columns = NULL ,
89
80
skip = skip ,
90
- id = id ,
91
- additional_gr_args_list = additional_gr_args_list
81
+ id = id
92
82
)
93
83
)
94
84
}
@@ -101,13 +91,13 @@ step_growth_rate_new <-
101
91
horizon ,
102
92
method ,
103
93
log_scale ,
94
+ na_rm ,
104
95
replace_Inf ,
105
96
prefix ,
106
97
keys ,
107
98
columns ,
108
99
skip ,
109
- id ,
110
- additional_gr_args_list ) {
100
+ id ) {
111
101
recipes :: step(
112
102
subclass = " growth_rate" ,
113
103
terms = terms ,
@@ -116,13 +106,13 @@ step_growth_rate_new <-
116
106
horizon = horizon ,
117
107
method = method ,
118
108
log_scale = log_scale ,
109
+ na_rm = na_rm ,
119
110
replace_Inf = replace_Inf ,
120
111
prefix = prefix ,
121
112
keys = keys ,
122
113
columns = columns ,
123
114
skip = skip ,
124
- id = id ,
125
- additional_gr_args_list = additional_gr_args_list
115
+ id = id
126
116
)
127
117
}
128
118
@@ -137,13 +127,13 @@ prep.step_growth_rate <- function(x, training, info = NULL, ...) {
137
127
horizon = x $ horizon ,
138
128
method = x $ method ,
139
129
log_scale = x $ log_scale ,
130
+ na_rm = x $ na_rm ,
140
131
replace_Inf = x $ replace_Inf ,
141
132
prefix = x $ prefix ,
142
133
keys = x $ keys ,
143
134
columns = recipes :: recipes_eval_select(x $ terms , training , info ),
144
135
skip = x $ skip ,
145
- id = x $ id ,
146
- additional_gr_args_list = x $ additional_gr_args_list
136
+ id = x $ id
147
137
)
148
138
}
149
139
@@ -177,10 +167,12 @@ bake.step_growth_rate <- function(object, new_data, ...) {
177
167
across(
178
168
all_of(object $ columns ),
179
169
~ epiprocess :: growth_rate(
180
- time_value , .x ,
170
+ .x ,
171
+ x = time_value ,
181
172
method = object $ method ,
182
- h = object $ horizon , log_scale = object $ log_scale ,
183
- !!! object $ additional_gr_args_list
173
+ h = object $ horizon ,
174
+ log_scale = object $ log_scale ,
175
+ na_rm = object $ na_rm
184
176
),
185
177
.names = " {object$prefix}{object$horizon}_{object$method}_{.col}"
186
178
)
0 commit comments