diff --git a/R/error.R b/R/error.R index e8b1c881..c0f3834e 100644 --- a/R/error.R +++ b/R/error.R @@ -38,16 +38,3 @@ not_tsibble <- function(x) { abort(sprintf("%s is not a tsibble.", deparse(substitute(x)))) } } - -pkg_not_available <- function(pkg, min_version = NULL) { - pkg_lgl <- requireNamespace(pkg, quietly = TRUE) - if (!pkg_lgl) { - abort(sprintf("Package `%s` required.\nPlease install and try again.", pkg)) - } else if (pkg_lgl && is_null(min_version)) { - return() - } else if (utils::packageVersion(pkg) < min_version) { - abort(sprintf( - "Package `%s` (>= v%s) required.\nPlease install and try again.", - pkg, min_version)) - } -} diff --git a/R/filter-index.R b/R/filter-index.R index ac411957..2f2e85ae 100644 --- a/R/filter-index.R +++ b/R/filter-index.R @@ -137,9 +137,7 @@ end_window.numeric <- function(x, y = NULL, ...) { #' @export start_window.difftime <- function(x, y = NULL, ...) { - if (!requireNamespace("hms", quietly = TRUE)) { - abort("Package `hms` required.\nPlease install and try again.") - } + check_installed("hms") if (is_null(y)) { hms::as_hms(min(x)) } else { diff --git a/R/holiday.R b/R/holiday.R index 8f478931..a192e07f 100644 --- a/R/holiday.R +++ b/R/holiday.R @@ -22,7 +22,7 @@ globalVariables("holiday") #' holiday_aus(2016, state = "VIC") #' holiday_aus(2013:2016, state = "ACT") holiday_aus <- function(year, state = "national") { - pkg_not_available("timeDate") + check_installed("timeDate") if (!is_integerish(year)) { abort("Argument `year` must be integers.") } diff --git a/R/scales.R b/R/scales.R index a6403a00..466b1f62 100644 --- a/R/scales.R +++ b/R/scales.R @@ -13,8 +13,8 @@ NULL scale_fun_pkg_check <- function() { - pkg_not_available("ggplot2", "3.3.0") - pkg_not_available("scales", "1.1.0") + check_installed("ggplot2", version = "3.3.0") + check_installed("scales", version = "1.1.0") } scale_type.yearquarter <- function(x) c("yearquarter", "date", "continuous")