Package 'using'

Title: Add version constraints to library() calls
Description: Add version constraints and remote git repositories to library() calls. In interactive mode the user is prompted to install.
Authors: Anthony North [aut, cre], Miles McBain [aut], Mango Solutions [cph], RStudio [cph]
Maintainer: Anthony North <[email protected]>
License: MIT + file LICENSE
Version: 0.4.0
Built: 2024-12-28 02:37:50 UTC
Source: https://github.com/anthonynorth/using

Help Index


detect_dependencies

Description

detect usage of using::pkg in a source file

Usage

detect_dependencies(file_path)

Arguments

file_path

a length 1 character vector file path to an .R or .Rmd file

Details

Intended for use when building lock files (e.g. for renv) from source files.

returns a data.frame of all information in using::pkg calls with columns: package, min_version, repo. The value of a row may be NA if the argument was not supplied.

Each result row is guaranteed to be unique, however the result data frame may contain near duplicates, e.g. using::pkg(janitor, min_version = "2.0.1") and using::pkg(janitor, min_version = "1.0.0") would each create a row in the result data frame if they appeared in the same file, due to differing min_version.

Each using::pkg call is parsed based on it's literal expression and no variable substitution is done. So using(janitor, min_version = janitor_ver) would place "janitor_ver" in the min_row column of the result for this dependency.

Value

a data.frame summarising found using::pkg calls in the supplied file.

Author(s)

Miles McBain


using::pkg

Description

Optionally add version constraints to library calls

Usage

pkg(package, min_version = NULL, repo = NULL, ...)

Arguments

package

{character | name} package name

min_version

{package_version | character} min package version

repo

{character} repo url

...

additional arguments to pass to base::library()

Details

This function is intended to always be called with the using:: prefix. A call without this prefix will throw a warning. This simplifies detecting dependencies declared by using::pkg for use with {renv} and {capsule}

Value

{character | logical} attached packages, or boolean if logical.return is TRUE

Examples

## Not run: 
using::pkg(capsule)
using::pkg(dplyr, min_version = "0.8.0")
using::pkg(h3jsr, min_version = "1.0.0", repo = "https://github.com/obrl-soil/h3jsr")

## End(Not run)

using

Description

Optionally add version constraints to library calls

Usage

using(...)

Arguments

...

arguments to pass to using::pkg()

Details

This is function is deprecated. See using::pkg().

Value

{character | logical} attached packages, or boolean if logical.return is TRUE

Examples

## Not run: 
using::pkg(capsule)
using::pkg(dplyr, min_version = "0.8.0")
using::pkg(h3jsr, min_version = "1.0.0", repo = "https://github.com/obrl-soil/h3jsr")

## End(Not run)