call_with_namespace: Load a package namespace and pass it to a function

Description Usage Arguments Value Examples

View source: R/plumbing.R

Description

The package is downloaded and installed if necessary, and its namespace is loaded. Then test(ns) is called with the namespace object, and its value is returned. On exit, the namespace is unloaded.

Usage

1
call_with_namespace(package, version, test, quiet = TRUE, ...)

Arguments

package

Package name.

version

Version as a character string.

test

A one-argument function.

quiet

Logical. Try to minimize output from package installation. (Some output comes from R CMD INSTALL and may be unavoidable.)

...

Arguments passed to versions::install.versions() or remotes::install_version(), and thence to install.packages(). Ncpus may be useful.

Value

The value returned by test.

Examples

1
2
3
4
5
## Not run: 
can_it_expand_urls <- function (namespace) "expand_urls" %in% names(namespace)
call_with_namespace("longurl", "0.3.0", test = can_it_expand_urls)

## End(Not run)

hughjonesd/apicheck documentation built on July 17, 2018, 7:21 a.m.