pkgapply: Apply an operation over several packages.

Description Usage Arguments Value Note See Also Examples

Description

This function is meant to be used by R developers that have to make simultaneous updates to many packages.

Usage

1
pkgapply(packages, dir = getwd(), f)

Arguments

packages

character. A character vector of package names. These must be directories relative to dir.

dir

character. The root directory on which to iterate over all the packages. By default, the current working directory.

f

function. The function to apply to each package. The argument the function receives is devtools::as.package(pkg_path), where pkg_path is the absolute path of the package. The output of this will be a list with a path key, as well as keys corresponding to each element in the DESCRIPTION file (title, version, etc.).

Value

A list where each element is the result of f applied to the respective package.

Note

The argument pkg received by the function call on each iteration is devtools::as.package(pkg_path), which has a $path available and whose other attributes originate directly from the package's DESCRIPTION file.

See Also

as.package

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
## Not run: 
  # You can use pkgapply to iterate over each package and apply some
  # operation.
  pkgapply(c('package1', 'package2'), dir = '/root/dir', function(pkg) { ... })
  pkgapply(c('package1', 'package2'), function(pkg) { ... })

  # If you leave the package names blank, it will loop over all directories
  # relative to `dir` that contain a DESCRIPTION file and are thus recognized
  # as being R packages.
  pkgapply(dir = '/root/dir', function(pkg) { ... })

  # If you do not provide a directory, the current directory will be used.
  pkgapply(function(pkg) { ... })

## End(Not run)

robertzk/packagepackage documentation built on May 27, 2019, 10:35 a.m.