Get an optional function without triggering a CRAN warning
Source:R/zz-deprecated-dependency-utils.R
optional_fn.Rd
You want to use a function if it is installed but don't want it to be installed as part of your package and you don't want to reference it as part of the Imports or Suggests fields in a package DESCRIPTION.
Usage
optional_fn(
pkg,
name,
alt = function(...) {
stop("function `", pkg, "::", name, "(...)` not available")
}
)
Arguments
- pkg
the package name
- name
the function you wish to use
- alt
a function that can be used instead
Examples
fn = .optional_fn("openssl", "md5", digest::digest)
as.character(fn(as.raw(c(1,2,3))))
#> [1] "5289df737df57326fcdd22597afb1fac"