Skip to content

Commit 46bb255

Browse files
committed
modified best_model function previously using dplyr::filter_() now deprecated to stay on CRAN. Switch to using a dplyr::filter() statement.
1 parent 2a9bad7 commit 46bb255

2 files changed

Lines changed: 21 additions & 7 deletions

File tree

NAMESPACE

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ export(update_obj)
118118
export(value)
119119
importFrom(Rcpp,evalCpp)
120120
importFrom(broom,glance)
121-
importFrom(dplyr,filter_)
121+
importFrom(dplyr,filter)
122122
importFrom(dplyr,group_by)
123123
importFrom(dplyr,mutate)
124124
importFrom(grDevices,col2rgb)

R/model_selection.R

Lines changed: 20 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -183,23 +183,37 @@ select_ma = function(xt, q.min = 0L, q.max = 3L,
183183
#' q.min = 1L, q.max = 3L)
184184
#' best_model(x, ic = "hq")
185185
#'
186-
#' @importFrom dplyr filter_
186+
#' @importFrom dplyr filter
187+
#' @importFrom magrittr %>%
187188
best_model = function(x, ic = "aic"){
189+
190+
191+
192+
188193

189194
criterion = switch(tolower(ic),
190195
"aic" = "AIC",
191196
"bic" = "BIC",
192197
"hq" = "HQ",
193198
stop("`criterion` not supported!"))
199+
200+
o <- x %>%
201+
dplyr::filter(ic == criterion, minval)
194202

195-
crt = paste0("ic == '", criterion,"' & (minval == TRUE)")
203+
o$models[[1]]$call$order <- c(o$p[[1]], o$d[[1]], o$q[[1]])
196204

197-
x %>%
198-
filter_(crt) -> o
205+
o$models[[1]]
199206

200-
o$models[[1]]$call$order = eval(parse(text=paste0("c(",o$p,",",o$d,",",o$q,")")))
201207

202-
o$models[[1]]
208+
# remove this due to filter_ is deprecated and filter_ is not working with the new version of dplyr
209+
# crt = paste0("ic == '", criterion,"' & (minval == TRUE)")
210+
#
211+
# x %>%
212+
# filter_(crt) -> o
213+
#
214+
# o$models[[1]]$call$order = eval(parse(text=paste0("c(",o$p,",",o$d,",",o$q,")")))
215+
#
216+
# o$models[[1]]
203217
}
204218

205219

0 commit comments

Comments
 (0)