Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 0 additions & 13 deletions R/error.R
Original file line number Diff line number Diff line change
Expand Up @@ -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))
}
}
4 changes: 1 addition & 3 deletions R/filter-index.R
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
2 changes: 1 addition & 1 deletion R/holiday.R
Original file line number Diff line number Diff line change
Expand Up @@ -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.")
}
Expand Down
4 changes: 2 additions & 2 deletions R/scales.R
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down