Title: | Create a Mini Version of CRAN Containing Only Selected Packages |
---|---|
Description: | Makes it possible to create an internally consistent repository consisting of selected packages from CRAN-like repositories. The user specifies a set of desired packages, and 'miniCRAN' recursively reads the dependency tree for these packages, then downloads only this subset. The user can then install packages from this repository directly, rather than from CRAN. This is useful in production settings, e.g. server behind a firewall, or remote locations with slow (or zero) Internet access. |
Authors: | Andrie de Vries [aut, cre, cph], Alex Chubaty [ctb], Microsoft Corporation [cph] |
Maintainer: | Andrie de Vries <[email protected]> |
License: | GPL-2 |
Version: | 0.3.0.9000 |
Built: | 2024-11-13 11:43:31 UTC |
Source: | https://github.com/andrie/minicran |
At the end of 2014, CRAN consisted of more than 6,000 packages. Many organisations need to maintain a private mirror of CRAN, but with only a subset of packages that are relevant to them.
miniCRAN
makes it possible to create an internally consistent repository
consisting of selected packages from CRAN-like repositories. The user
specifies a set of desired packages, and miniCRAN recursively reads the
dependency tree for these packages, then downloads only this subset.
There are many reasons for not creating a complete mirror CRAN using rsync
:
You may wish to mirror only a subset of CRAN, for security, legal compliance or any other in-house reason
You may wish to restrict internal package use to a subset of public packages, to minimize package duplication, or other reasons of coding standards
You may wish to make packages available from public repositories other than CRAN, e.g. BioConductor, r-forge, OmegaHat, etc.
You may wish to add custom in-house packages to your repository
The ambition of miniCRAN
is to eventually satisfy all of these
considerations.
pkgAvail()
: Read from a local (or remote) CRAN-like repository and
determine available packages.
pkgDep()
: Find (recursive) package dependencies.
makeRepo()
: Make a mini CRAN repository, by downloading packages (and
their dependencies) and creating the appropriate file structure for a
repository. This allows you to use functions like
utils::available.packages()
and utils::install.packages()
on your local
repository.
This subset will be internally consistent, i.e. the following functions will work as expected:
The main function is makeRepo()
- this will download all the required
packages, with their dependencies, into the appropriate repository file
structure, and then create the repository index (PACKAGES) file.
oldPackages()
: Indicates packages which have a (suitable) later version
on the repositories * updatePackages()
: Offers to download and install
such packages
To get a recursive list of dependencies as well as a plot, use pkgDep()
followed by makeDepGraph()
.
pkgDep()
: Find (recursive) package dependencies.
makeDepGraph()
: Create graph of selected package dependencies.
plot.pkgDepGraph()
: Create a visualization of the dependency graph
minicran.mran
preferred p3m URL. Defaults to https://packagemanager.posit.co/cran for R versions 3.2.2 and greater. Versions earlier than 3.2.2 use HTTP instead of HTTPS.
Maintainer: Andrie de Vries [email protected] [copyright holder]
Other contributors:
Alex Chubaty [email protected] [contributor]
Microsoft Corporation [copyright holder]
Useful links:
List pre-built packages in a directory based on file extension
.listFiles(pkgs, path, type)
.listFiles(pkgs, path, type)
pkgs |
Character vector of package names |
path |
Character string specifying the directory containing packages to be added. |
type |
Character indicating the package type (e.g., "source", "win.binary", etc.). |
Installs the packages and returns the new package index.
## Not run: .listFiles('path/to/my/packages', type = "source") ## End(Not run)
## Not run: .listFiles('path/to/my/packages', type = "source") ## End(Not run)
Examine the contents of a directory specified by pkgPath
for pre-built
packages matching the names specified by pkgs
, and add these to the
miniCRAN repository.
addLocalPackage( pkgs = NULL, pkgPath = NULL, path = NULL, type = "source", Rversion = R.version, writePACKAGES = TRUE, deps = FALSE, quiet = FALSE, build = FALSE )
addLocalPackage( pkgs = NULL, pkgPath = NULL, path = NULL, type = "source", Rversion = R.version, writePACKAGES = TRUE, deps = FALSE, quiet = FALSE, build = FALSE )
pkgs |
Character vector of packages to download |
pkgPath |
Character vector of directory location containing packages to
be added. Note that |
path |
Destination download path. This path is the root folder of your new repository. |
type |
Possible values are (currently) "source", "mac.binary" and
"win.binary": the binary types can be listed and downloaded but not
installed on other platforms. Passed to |
Rversion |
Version of R (only used if
|
writePACKAGES |
If TRUE, calls |
deps |
Not used. See note. |
quiet |
If TRUE, suppress status messages (if any), and the progress bar during download. |
build |
Logical indicating whether packages should be build prior to adding. |
To build a package from source and then add it, use build = TRUE
. Note that
package development libraries and the devtools
package must be installed on
your system in order to build packages.
Installs the packages and returns the new package index.
Currently, adding local packages does not check nor download their dependencies.
Alex Chubaty
## Not run: addLocalPackage("myPackage", "path/to/my/prebuilt/package", "path/to/my/miniCRAN/repo") addLocalPackage("myPackage", "path/to/my/package/sourcecode", "path/to/my/miniCRAN/repo", build = TRUE) ## End(Not run)
## Not run: addLocalPackage("myPackage", "path/to/my/prebuilt/package", "path/to/my/miniCRAN/repo") addLocalPackage("myPackage", "path/to/my/package/sourcecode", "path/to/my/miniCRAN/repo", build = TRUE) ## End(Not run)
Will download and add older source package versions. Older binary versions
are not normally available on CRAN and should be built from source on the
platform for which they are required. As such, specifying type!="source"
will likely fail as the download will not be successful.
addOldPackage( pkgs = NULL, path = NULL, vers = NULL, repos = getOption("repos"), type = "source", Rversion = R.version, writePACKAGES = TRUE, deps = FALSE, quiet = TRUE )
addOldPackage( pkgs = NULL, path = NULL, vers = NULL, repos = getOption("repos"), type = "source", Rversion = R.version, writePACKAGES = TRUE, deps = FALSE, quiet = TRUE )
pkgs |
Character vector of packages to download |
path |
Destination download path. This path is the root folder of your new repository. |
vers |
The package version to install. |
repos |
URL(s) of the 'contrib' sections of the repositories, e.g.
|
type |
Possible values are (currently) "source", "mac.binary" and
"win.binary": the binary types can be listed and downloaded but not
installed on other platforms. Passed to |
Rversion |
Version of R (only used if
|
writePACKAGES |
If TRUE, calls |
deps |
logical indicating whether the package dependencies should be
added (default |
quiet |
If TRUE, suppress status messages (if any), and the progress bar during download. |
Adds the packages, rebuilds the package index, and invisibly returns the number of packages written to the index files.
Dependencies for old package versions cannot be determined
automatically and must be specified by the user in pkgs
and vers
. Thus,
deps=FALSE
is the default for this function.
Other update repo functions:
addPackage()
,
checkVersions()
,
makeRepo()
,
updatePackages()
### `checkVersions` and `add.packages.miniCRAN` require an existing miniCRAN repo # Specify list of packages to download mirror <- c(CRAN = "https://cloud.r-project.org") mirror pkgs <- c("foreach") pkgTypes <- c("source", "win.binary") if (interactive()) { if (!is.online()) { message("p3m seems to be not available. Check your internet connection.") } else { pdb <- pkgAvail(repos = mirror, type = "source") } } else { pdb <- cranJuly2014 } if (interactive()) { if (!is.online()) { message("p3m seems to be not available. Check your internet connection.") } else { pkgList <- pkgDep(pkgs, availPkgs = pdb, repos = mirror, type = "source", suggests = FALSE) pkgList } } # Create temporary folder for miniCRAN if (interactive()) { if (!is.online()) { message("p3m seems to be not available. Check your internet connection.") } else { dir.create(pth <- file.path(tempdir(), "miniCRAN")) # Make repo for source and win.binary makeRepo(pkgList, path = pth, repos = mirror, type = pkgTypes) # Add other versions of a package (and assume these were added previously) oldVers <- data.frame( package = c("foreach", "codetools", "iterators"), version = c("1.4.0", "0.2-7", "1.0.5"), stringsAsFactors = FALSE ) pkgs <- oldVers$package addOldPackage(pkgs, path = pth, vers = oldVers$version, repos = mirror, type = "source") # NOTE: older binary versions would need to be build from source # List package versions in the miniCRAN repo (produces warning about duplicates) pkgVersionsSrc <- checkVersions(pkgs, path = pth, type = "source") pkgVersionsBin <- checkVersions(pkgs, path = pth, type = "win.binary") # After inspecting package versions, remove old versions basename(pkgVersionsSrc$source) # "foreach_1.4.0.tar.gz" "foreach_1.4.2.tar.gz" basename(pkgVersionsBin$win.binary) # "foreach_1.4.0.zip" "foreach_1.4.2.zip" file.remove(c(pkgVersionsSrc$source[1], pkgVersionsBin$win.binary[1])) # Rebuild package index after adding/removing files updateRepoIndex(pth, type = pkgTypes, Rversion = R.version) pkgAvail(pth, type = "source") # Add new packages (from CRAN) to the miniCRAN repo addPackage("Matrix", path = pth, repos = mirror, type = pkgTypes) # Delete temporary folder unlink(pth, recursive = TRUE) } }
### `checkVersions` and `add.packages.miniCRAN` require an existing miniCRAN repo # Specify list of packages to download mirror <- c(CRAN = "https://cloud.r-project.org") mirror pkgs <- c("foreach") pkgTypes <- c("source", "win.binary") if (interactive()) { if (!is.online()) { message("p3m seems to be not available. Check your internet connection.") } else { pdb <- pkgAvail(repos = mirror, type = "source") } } else { pdb <- cranJuly2014 } if (interactive()) { if (!is.online()) { message("p3m seems to be not available. Check your internet connection.") } else { pkgList <- pkgDep(pkgs, availPkgs = pdb, repos = mirror, type = "source", suggests = FALSE) pkgList } } # Create temporary folder for miniCRAN if (interactive()) { if (!is.online()) { message("p3m seems to be not available. Check your internet connection.") } else { dir.create(pth <- file.path(tempdir(), "miniCRAN")) # Make repo for source and win.binary makeRepo(pkgList, path = pth, repos = mirror, type = pkgTypes) # Add other versions of a package (and assume these were added previously) oldVers <- data.frame( package = c("foreach", "codetools", "iterators"), version = c("1.4.0", "0.2-7", "1.0.5"), stringsAsFactors = FALSE ) pkgs <- oldVers$package addOldPackage(pkgs, path = pth, vers = oldVers$version, repos = mirror, type = "source") # NOTE: older binary versions would need to be build from source # List package versions in the miniCRAN repo (produces warning about duplicates) pkgVersionsSrc <- checkVersions(pkgs, path = pth, type = "source") pkgVersionsBin <- checkVersions(pkgs, path = pth, type = "win.binary") # After inspecting package versions, remove old versions basename(pkgVersionsSrc$source) # "foreach_1.4.0.tar.gz" "foreach_1.4.2.tar.gz" basename(pkgVersionsBin$win.binary) # "foreach_1.4.0.zip" "foreach_1.4.2.zip" file.remove(c(pkgVersionsSrc$source[1], pkgVersionsBin$win.binary[1])) # Rebuild package index after adding/removing files updateRepoIndex(pth, type = pkgTypes, Rversion = R.version) pkgAvail(pth, type = "source") # Add new packages (from CRAN) to the miniCRAN repo addPackage("Matrix", path = pth, repos = mirror, type = pkgTypes) # Delete temporary folder unlink(pth, recursive = TRUE) } }
Add packages to a miniCRAN repository.
addPackage( pkgs = NULL, path = NULL, repos = getOption("repos"), type = "source", Rversion = R.version, writePACKAGES = TRUE, deps = TRUE, quiet = FALSE )
addPackage( pkgs = NULL, path = NULL, repos = getOption("repos"), type = "source", Rversion = R.version, writePACKAGES = TRUE, deps = TRUE, quiet = FALSE )
pkgs |
Character vector of packages to download |
path |
Destination download path. This path is the root folder of your new repository. |
repos |
URL(s) of the 'contrib' sections of the repositories, e.g.
|
type |
Possible values are (currently) "source", "mac.binary" and
"win.binary": the binary types can be listed and downloaded but not
installed on other platforms. Passed to |
Rversion |
Version of R (only used if
|
writePACKAGES |
If TRUE, calls |
deps |
logical indicating whether the package dependencies should be
added (default |
quiet |
If TRUE, suppress status messages (if any), and the progress bar during download. |
Installs the packages, rebuilds the package index, and invisibly returns the number of packages written to the index files.
Other update repo functions:
addOldPackage()
,
checkVersions()
,
makeRepo()
,
updatePackages()
### `checkVersions` and `add.packages.miniCRAN` require an existing miniCRAN repo # Specify list of packages to download mirror <- c(CRAN = "https://cloud.r-project.org") mirror pkgs <- c("foreach") pkgTypes <- c("source", "win.binary") if (interactive()) { if (!is.online()) { message("p3m seems to be not available. Check your internet connection.") } else { pdb <- pkgAvail(repos = mirror, type = "source") } } else { pdb <- cranJuly2014 } if (interactive()) { if (!is.online()) { message("p3m seems to be not available. Check your internet connection.") } else { pkgList <- pkgDep(pkgs, availPkgs = pdb, repos = mirror, type = "source", suggests = FALSE) pkgList } } # Create temporary folder for miniCRAN if (interactive()) { if (!is.online()) { message("p3m seems to be not available. Check your internet connection.") } else { dir.create(pth <- file.path(tempdir(), "miniCRAN")) # Make repo for source and win.binary makeRepo(pkgList, path = pth, repos = mirror, type = pkgTypes) # Add other versions of a package (and assume these were added previously) oldVers <- data.frame( package = c("foreach", "codetools", "iterators"), version = c("1.4.0", "0.2-7", "1.0.5"), stringsAsFactors = FALSE ) pkgs <- oldVers$package addOldPackage(pkgs, path = pth, vers = oldVers$version, repos = mirror, type = "source") # NOTE: older binary versions would need to be build from source # List package versions in the miniCRAN repo (produces warning about duplicates) pkgVersionsSrc <- checkVersions(pkgs, path = pth, type = "source") pkgVersionsBin <- checkVersions(pkgs, path = pth, type = "win.binary") # After inspecting package versions, remove old versions basename(pkgVersionsSrc$source) # "foreach_1.4.0.tar.gz" "foreach_1.4.2.tar.gz" basename(pkgVersionsBin$win.binary) # "foreach_1.4.0.zip" "foreach_1.4.2.zip" file.remove(c(pkgVersionsSrc$source[1], pkgVersionsBin$win.binary[1])) # Rebuild package index after adding/removing files updateRepoIndex(pth, type = pkgTypes, Rversion = R.version) pkgAvail(pth, type = "source") # Add new packages (from CRAN) to the miniCRAN repo addPackage("Matrix", path = pth, repos = mirror, type = pkgTypes) # Delete temporary folder unlink(pth, recursive = TRUE) } }
### `checkVersions` and `add.packages.miniCRAN` require an existing miniCRAN repo # Specify list of packages to download mirror <- c(CRAN = "https://cloud.r-project.org") mirror pkgs <- c("foreach") pkgTypes <- c("source", "win.binary") if (interactive()) { if (!is.online()) { message("p3m seems to be not available. Check your internet connection.") } else { pdb <- pkgAvail(repos = mirror, type = "source") } } else { pdb <- cranJuly2014 } if (interactive()) { if (!is.online()) { message("p3m seems to be not available. Check your internet connection.") } else { pkgList <- pkgDep(pkgs, availPkgs = pdb, repos = mirror, type = "source", suggests = FALSE) pkgList } } # Create temporary folder for miniCRAN if (interactive()) { if (!is.online()) { message("p3m seems to be not available. Check your internet connection.") } else { dir.create(pth <- file.path(tempdir(), "miniCRAN")) # Make repo for source and win.binary makeRepo(pkgList, path = pth, repos = mirror, type = pkgTypes) # Add other versions of a package (and assume these were added previously) oldVers <- data.frame( package = c("foreach", "codetools", "iterators"), version = c("1.4.0", "0.2-7", "1.0.5"), stringsAsFactors = FALSE ) pkgs <- oldVers$package addOldPackage(pkgs, path = pth, vers = oldVers$version, repos = mirror, type = "source") # NOTE: older binary versions would need to be build from source # List package versions in the miniCRAN repo (produces warning about duplicates) pkgVersionsSrc <- checkVersions(pkgs, path = pth, type = "source") pkgVersionsBin <- checkVersions(pkgs, path = pth, type = "win.binary") # After inspecting package versions, remove old versions basename(pkgVersionsSrc$source) # "foreach_1.4.0.tar.gz" "foreach_1.4.2.tar.gz" basename(pkgVersionsBin$win.binary) # "foreach_1.4.0.zip" "foreach_1.4.2.zip" file.remove(c(pkgVersionsSrc$source[1], pkgVersionsBin$win.binary[1])) # Rebuild package index after adding/removing files updateRepoIndex(pth, type = pkgTypes, Rversion = R.version) pkgAvail(pth, type = "source") # Add new packages (from CRAN) to the miniCRAN repo addPackage("Matrix", path = pth, repos = mirror, type = pkgTypes) # Delete temporary folder unlink(pth, recursive = TRUE) } }
Downloads the DESCRIPTION file from a package on github, parses the fields and adds (or replaces) a row in the available package database.
addPackageListingGithub( pdb = pkgAvail(), repo, username = NULL, branch = "main" )
addPackageListingGithub( pdb = pkgAvail(), repo, username = NULL, branch = "main" )
pdb |
Package database, usually the result of |
repo |
Character vector. Name of repository on github, e.g.
|
username |
Optional character vector. Name of repository on github, e.g.
|
branch |
name of branch, defaults to |
# Create package database pdb <- cranJuly2014 if (interactive()) { pdb <- pkgAvail(repos = c(CRAN = "https://cloud.r-project.org")) # Overwrite pdb with development version of miniCRAN at github newpdb <- addPackageListingGithub(pdb = pdb, "andrie/miniCRAN") newpdb["miniCRAN", ] # Add package from github that's not currently on CRAN newpdb <- addPackageListingGithub(pdb = pdb, repo = "tidyverse/ggplot2", branch = "main") newpdb["ggplot2", ] set.seed(1) plot(makeDepGraph("ggplot2", availPkgs = newpdb, suggests = TRUE)) }
# Create package database pdb <- cranJuly2014 if (interactive()) { pdb <- pkgAvail(repos = c(CRAN = "https://cloud.r-project.org")) # Overwrite pdb with development version of miniCRAN at github newpdb <- addPackageListingGithub(pdb = pdb, "andrie/miniCRAN") newpdb["miniCRAN", ] # Add package from github that's not currently on CRAN newpdb <- addPackageListingGithub(pdb = pdb, repo = "tidyverse/ggplot2", branch = "main") newpdb["ggplot2", ] set.seed(1) plot(makeDepGraph("ggplot2", availPkgs = newpdb, suggests = TRUE)) }
Retrieves names of installed packages by calling
utils::installed.packages()
and returning only those packages where
Priority == "base"
.
basePkgs()
basePkgs()
Other dependency functions:
makeDepGraph()
,
pkgDep()
,
plot.pkgDepGraph()
Checks for previous versions, and returns the file paths for packages with multiple versions. You can subsequently decide which version to keep.
checkVersions(pkgs = NULL, path = NULL, type = "source", Rversion = R.version)
checkVersions(pkgs = NULL, path = NULL, type = "source", Rversion = R.version)
pkgs |
Character vector of packages to be installed. If not provided, checks all files for multiple package versions. |
path |
The local path to the directory where the miniCRAN repo resides. |
type |
character, indicating the type of package to download and
install. See |
Rversion |
Version of R (only used if
|
Returns invisibly the file paths to packages with multiple versions for removal.
list with an element for each type
, consisting of a character
vector of download paths
Other update repo functions:
addOldPackage()
,
addPackage()
,
makeRepo()
,
updatePackages()
### `checkVersions` and `add.packages.miniCRAN` require an existing miniCRAN repo # Specify list of packages to download mirror <- c(CRAN = "https://cloud.r-project.org") mirror pkgs <- c("foreach") pkgTypes <- c("source", "win.binary") if (interactive()) { if (!is.online()) { message("p3m seems to be not available. Check your internet connection.") } else { pdb <- pkgAvail(repos = mirror, type = "source") } } else { pdb <- cranJuly2014 } if (interactive()) { if (!is.online()) { message("p3m seems to be not available. Check your internet connection.") } else { pkgList <- pkgDep(pkgs, availPkgs = pdb, repos = mirror, type = "source", suggests = FALSE) pkgList } } # Create temporary folder for miniCRAN if (interactive()) { if (!is.online()) { message("p3m seems to be not available. Check your internet connection.") } else { dir.create(pth <- file.path(tempdir(), "miniCRAN")) # Make repo for source and win.binary makeRepo(pkgList, path = pth, repos = mirror, type = pkgTypes) # Add other versions of a package (and assume these were added previously) oldVers <- data.frame( package = c("foreach", "codetools", "iterators"), version = c("1.4.0", "0.2-7", "1.0.5"), stringsAsFactors = FALSE ) pkgs <- oldVers$package addOldPackage(pkgs, path = pth, vers = oldVers$version, repos = mirror, type = "source") # NOTE: older binary versions would need to be build from source # List package versions in the miniCRAN repo (produces warning about duplicates) pkgVersionsSrc <- checkVersions(pkgs, path = pth, type = "source") pkgVersionsBin <- checkVersions(pkgs, path = pth, type = "win.binary") # After inspecting package versions, remove old versions basename(pkgVersionsSrc$source) # "foreach_1.4.0.tar.gz" "foreach_1.4.2.tar.gz" basename(pkgVersionsBin$win.binary) # "foreach_1.4.0.zip" "foreach_1.4.2.zip" file.remove(c(pkgVersionsSrc$source[1], pkgVersionsBin$win.binary[1])) # Rebuild package index after adding/removing files updateRepoIndex(pth, type = pkgTypes, Rversion = R.version) pkgAvail(pth, type = "source") # Add new packages (from CRAN) to the miniCRAN repo addPackage("Matrix", path = pth, repos = mirror, type = pkgTypes) # Delete temporary folder unlink(pth, recursive = TRUE) } }
### `checkVersions` and `add.packages.miniCRAN` require an existing miniCRAN repo # Specify list of packages to download mirror <- c(CRAN = "https://cloud.r-project.org") mirror pkgs <- c("foreach") pkgTypes <- c("source", "win.binary") if (interactive()) { if (!is.online()) { message("p3m seems to be not available. Check your internet connection.") } else { pdb <- pkgAvail(repos = mirror, type = "source") } } else { pdb <- cranJuly2014 } if (interactive()) { if (!is.online()) { message("p3m seems to be not available. Check your internet connection.") } else { pkgList <- pkgDep(pkgs, availPkgs = pdb, repos = mirror, type = "source", suggests = FALSE) pkgList } } # Create temporary folder for miniCRAN if (interactive()) { if (!is.online()) { message("p3m seems to be not available. Check your internet connection.") } else { dir.create(pth <- file.path(tempdir(), "miniCRAN")) # Make repo for source and win.binary makeRepo(pkgList, path = pth, repos = mirror, type = pkgTypes) # Add other versions of a package (and assume these were added previously) oldVers <- data.frame( package = c("foreach", "codetools", "iterators"), version = c("1.4.0", "0.2-7", "1.0.5"), stringsAsFactors = FALSE ) pkgs <- oldVers$package addOldPackage(pkgs, path = pth, vers = oldVers$version, repos = mirror, type = "source") # NOTE: older binary versions would need to be build from source # List package versions in the miniCRAN repo (produces warning about duplicates) pkgVersionsSrc <- checkVersions(pkgs, path = pth, type = "source") pkgVersionsBin <- checkVersions(pkgs, path = pth, type = "win.binary") # After inspecting package versions, remove old versions basename(pkgVersionsSrc$source) # "foreach_1.4.0.tar.gz" "foreach_1.4.2.tar.gz" basename(pkgVersionsBin$win.binary) # "foreach_1.4.0.zip" "foreach_1.4.2.zip" file.remove(c(pkgVersionsSrc$source[1], pkgVersionsBin$win.binary[1])) # Rebuild package index after adding/removing files updateRepoIndex(pth, type = pkgTypes, Rversion = R.version) pkgAvail(pth, type = "source") # Add new packages (from CRAN) to the miniCRAN repo addPackage("Matrix", path = pth, repos = mirror, type = pkgTypes) # Delete temporary folder unlink(pth, recursive = TRUE) } }
Copy of the result of utils::available.packages()
on July 1, 2014.
cranJuly2014
cranJuly2014
matrix
This is a wrapper around tools::CRAN_package_db
and may be
deprecated in future versions of the package.
getCranDescription( pkg, repos = getOption("repos"), type = "source", pkgs = pkgDep(pkg, repos = repos, type = type) )
getCranDescription( pkg, repos = getOption("repos"), type = "source", pkgs = pkgDep(pkg, repos = repos, type = type) )
pkg |
Character vector of packages. |
repos |
URL(s) of the 'contrib' sections of the repositories, e.g.
|
type |
Possible values are (currently) "source", "mac.binary" and
"win.binary": the binary types can be listed and downloaded but not
installed on other platforms. Passed to |
pkgs |
Character vector of packages to download |
if (interactive()) { getCranDescription(c("igraph", "ggplot2", "XML"), repos = c(CRAN = getOption("minicran.mran")) ) }
if (interactive()) { getCranDescription(c("igraph", "ggplot2", "XML"), repos = c(CRAN = getOption("minicran.mran")) ) }
Returns TRUE if the p3m URL can be accessed.
is.online(url = NULL, tryHttp = TRUE)
is.online(url = NULL, tryHttp = TRUE)
url |
p3m url |
tryHttp |
If TRUE, also attempts http URL, for compatibility with older versions of R |
Each package is a node, and a dependency is an edge
makeDepGraph( pkg, availPkgs, repos = getOption("repos"), type = "source", suggests = TRUE, enhances = FALSE, includeBasePkgs = FALSE, ... )
makeDepGraph( pkg, availPkgs, repos = getOption("repos"), type = "source", suggests = TRUE, enhances = FALSE, includeBasePkgs = FALSE, ... )
pkg |
Character vector of packages. |
availPkgs |
Data frame with an element called |
repos |
URL(s) of the 'contrib' sections of the repositories, e.g.
|
type |
Possible values are (currently) "source", "mac.binary" and
"win.binary": the binary types can be listed and downloaded but not
installed on other platforms. Passed to |
suggests |
If TRUE, retrieves Suggests dependencies (non-recursively) |
enhances |
If TRUE, retrieves Enhances dependencies (non-recursively) |
includeBasePkgs |
If TRUE, include base R packages in results |
... |
Other arguments passed to |
pkgDep()
to extract package dependencies
Other dependency functions:
basePkgs()
,
pkgDep()
,
plot.pkgDepGraph()
if (interactive()) { availPkgs <- cranJuly2014 availPkgs <- pkgAvail( repos = c(CRAN = "https://cloud.r-project.org"), type = "source" ) # Create dependency graph using stored database of available packages p <- makeDepGraph( c("ggplot2", "forecast"), availPkgs = availPkgs ) if(require(igraph)) plot(p) # Create dependency graph using newly retrieved database from CRAN p <- makeDepGraph( c("ggplot2", "forecast"), repos = c(CRAN = getOption("minicran.mran")), type = "source" ) if(requireNamespace("igraph", quietly = TRUE)) { plot(p) } else { message("install package `igraph` to view dependency graph") } }
if (interactive()) { availPkgs <- cranJuly2014 availPkgs <- pkgAvail( repos = c(CRAN = "https://cloud.r-project.org"), type = "source" ) # Create dependency graph using stored database of available packages p <- makeDepGraph( c("ggplot2", "forecast"), availPkgs = availPkgs ) if(require(igraph)) plot(p) # Create dependency graph using newly retrieved database from CRAN p <- makeDepGraph( c("ggplot2", "forecast"), repos = c(CRAN = getOption("minicran.mran")), type = "source" ) if(requireNamespace("igraph", quietly = TRUE)) { plot(p) } else { message("install package `igraph` to view dependency graph") } }
Deprecated function to download packages to local folder.
makeLibrary(pkgs, path, type = "source")
makeLibrary(pkgs, path, type = "source")
pkgs |
Character vector of packages to download |
path |
Destination download path. This path is the root folder of your new repository. |
type |
Possible values are (currently) "source", "mac.binary" and
"win.binary": the binary types can be listed and downloaded but not
installed on other platforms. Passed to |
Given a list of packages, downloads these packages to a specified destination
folder using the required CRAN folder structure, and finally creates the
PACKAGES index file. Since the folder structure mimics the required
structure and files of a CRAN repository, it supports functions like
utils::install.packages()
.
makeRepo( pkgs, path, repos = getOption("repos"), type = "source", Rversion = R.version, download = TRUE, writePACKAGES = TRUE, filters = NULL, quiet = FALSE ) updateRepoIndex(path, type = "source", Rversion = R.version)
makeRepo( pkgs, path, repos = getOption("repos"), type = "source", Rversion = R.version, download = TRUE, writePACKAGES = TRUE, filters = NULL, quiet = FALSE ) updateRepoIndex(path, type = "source", Rversion = R.version)
pkgs |
Character vector of packages to download |
path |
Destination download path. This path is the root folder of your new repository. |
repos |
URL(s) of the 'contrib' sections of the repositories, e.g.
|
type |
Possible values are (currently) "source", "mac.binary" and
"win.binary": the binary types can be listed and downloaded but not
installed on other platforms. Passed to |
Rversion |
Version of R (only used if
|
download |
If TRUE downloads packages. |
writePACKAGES |
If TRUE, calls |
filters |
passed to utils::available.packages |
quiet |
If TRUE, suppress status messages (if any), and the progress bar during download. |
character vector of downloaded package files
A repository has two main folders, one for source packages, and the other
for binary packages. Inside the binary package folder, bin
, you will find
subfolders for Windows as well as the various OSX binaries.
+- Root
...+- src/contrib
......+- PACKAGES
..+- bin
.......+- windows/contrib/version
..........+- PACKAGES
.......+- macosx/contrib/version
..........+- PACKAGES
.......+- macosx/mavericks/contrib/version
..........+- PACKAGES
.......+- macosx/leopard/contrib/version
..........+- PACKAGES
Internally makes use of utils::download.packages()
and
write_PACKAGES()
Other update repo functions:
addOldPackage()
,
addPackage()
,
checkVersions()
,
updatePackages()
# Specify list of packages to download mirror <- c(CRAN = "https://cloud.r-project.org") pkgs <- c("foreach") if (interactive()) { pdb <- cranJuly2014 pdb <- pkgAvail( repos = c(CRAN = getOption("minicran.mran")), type = "source" ) pkgList <- pkgDep(pkgs, availPkgs = pdb, repos = mirror, type = "source", suggests = FALSE) pkgList # Create temporary folder for miniCRAN dir.create(pth <- file.path(tempdir(), "miniCRAN")) # Make repo for source and win.binary makeRepo(pkgList, path = pth, repos = mirror, type = "source") # List all files in miniCRAN list.files(pth, recursive = TRUE) # Check for available packages pkgAvail(repos = pth, type = "source") # Repeat process for windows binaries makeRepo(pkgList, path = pth, repos = mirror, type = "win.binary") pkgAvail(repos = pth, type = "win.binary") # Delete temporary folder unlink(pth, recursive = TRUE) }
# Specify list of packages to download mirror <- c(CRAN = "https://cloud.r-project.org") pkgs <- c("foreach") if (interactive()) { pdb <- cranJuly2014 pdb <- pkgAvail( repos = c(CRAN = getOption("minicran.mran")), type = "source" ) pkgList <- pkgDep(pkgs, availPkgs = pdb, repos = mirror, type = "source", suggests = FALSE) pkgList # Create temporary folder for miniCRAN dir.create(pth <- file.path(tempdir(), "miniCRAN")) # Make repo for source and win.binary makeRepo(pkgList, path = pth, repos = mirror, type = "source") # List all files in miniCRAN list.files(pth, recursive = TRUE) # Check for available packages pkgAvail(repos = pth, type = "source") # Repeat process for windows binaries makeRepo(pkgList, path = pth, repos = mirror, type = "win.binary") pkgAvail(repos = pth, type = "win.binary") # Delete temporary folder unlink(pth, recursive = TRUE) }
This is a thin wrapper around utils::available.packages()
. If the argument
path
is supplied, then the function attempts to read from a local
repository, otherwise attempts to read from a CRAN mirror at the repos
url.
pkgAvail( repos = getOption("repos"), type = "source", Rversion = R.version, quiet = FALSE, filters = NULL )
pkgAvail( repos = getOption("repos"), type = "source", Rversion = R.version, quiet = FALSE, filters = NULL )
repos |
URL(s) of the 'contrib' sections of the repositories, e.g.
|
type |
Possible values are (currently) "source", "mac.binary" and
"win.binary": the binary types can be listed and downloaded but not
installed on other platforms. Passed to |
Rversion |
Version of R (only used if
|
quiet |
If TRUE, suppresses warnings |
filters |
passed to utils::available.packages |
Performs recursive retrieve for Depends
, Imports
and LinkLibrary
.
Performs non-recursive retrieve for Suggests
.
pkgDep( pkg, availPkgs, repos = getOption("repos"), type = "source", depends = TRUE, suggests = TRUE, enhances = FALSE, includeBasePkgs = FALSE, Rversion = R.version, quiet = FALSE, ... )
pkgDep( pkg, availPkgs, repos = getOption("repos"), type = "source", depends = TRUE, suggests = TRUE, enhances = FALSE, includeBasePkgs = FALSE, Rversion = R.version, quiet = FALSE, ... )
pkg |
Character vector of packages. |
availPkgs |
Data frame with an element called |
repos |
URL(s) of the 'contrib' sections of the repositories, e.g.
|
type |
Possible values are (currently) "source", "mac.binary" and
"win.binary": the binary types can be listed and downloaded but not
installed on other platforms. Passed to |
depends |
If TRUE, retrieves |
suggests |
If TRUE, retrieves Suggests dependencies (non-recursively) |
enhances |
If TRUE, retrieves Enhances dependencies (non-recursively) |
includeBasePkgs |
If TRUE, include base R packages in results |
Rversion |
Version of R (only used if
|
quiet |
If TRUE, suppresses warnings |
... |
Other arguments passed to |
character vector of package names
Other dependency functions:
basePkgs()
,
makeDepGraph()
,
plot.pkgDepGraph()
if (interactive()) { pkgDep(pkg = c("ggplot2", "plyr", "reshape2"), repos = c(CRAN = "https://cloud.r-project.org") ) pdb <- cranJuly2014 pdb <- pkgAvail(repos = c(CRAN = getOption("minicran.mran"))) pkgDep(pkg = c("ggplot2", "plyr", "reshape2"), pdb) }
if (interactive()) { pkgDep(pkg = c("ggplot2", "plyr", "reshape2"), repos = c(CRAN = "https://cloud.r-project.org") ) pdb <- cranJuly2014 pdb <- pkgAvail(repos = c(CRAN = getOption("minicran.mran"))) pkgDep(pkg = c("ggplot2", "plyr", "reshape2"), pdb) }
Plots a package dependency graph.
## S3 method for class 'pkgDepGraph' plot( x, pkgsToHighlight, main = paste(attr(x, "pkgs"), collapse = ", "), legendPosition = c(-1.2, -1), shape = "circle", vertex.size = 8, cex = 1, ... )
## S3 method for class 'pkgDepGraph' plot( x, pkgsToHighlight, main = paste(attr(x, "pkgs"), collapse = ", "), legendPosition = c(-1.2, -1), shape = "circle", vertex.size = 8, cex = 1, ... )
x |
Object to plot |
pkgsToHighlight |
Optional character vector with names of package to
highlight. If missing, defaults to packages used in original call to
|
main |
Title of plot |
legendPosition |
Numeric vector of length 2, indicating (x, y) position
of edge legend. Both values should be in the range |
shape |
Shape of edge. See |
vertex.size |
Size of vertex shape. |
cex |
Vertex label size. |
... |
Ignored |
Other dependency functions:
basePkgs()
,
makeDepGraph()
,
pkgDep()
tags <- "chron" # Plot using defaults if (interactive()){ pdb <- pkgAvail( repos = c(CRAN = getOption("minicran.mran")), type = "source" ) } else { pdb <- cranJuly2014 } if (interactive()) { dg <- makeDepGraph(tags, availPkgs = pdb , includeBasePkgs = FALSE, suggests = TRUE, enhances = TRUE) set.seed(43); plot(dg) # Move edge legend to top left set.seed(42); plot(dg, legendPosition = c(-1, 1)) # Change font size and shape size set.seed(42); plot(dg, legendPosition = c(-1, 1), vertex.size = 20, cex = 0.5) # Move vertex legend to top right set.seed(42); plot(dg, legendPosition = c(1, 1), vertex.size = 20, cex = 0.5) }
tags <- "chron" # Plot using defaults if (interactive()){ pdb <- pkgAvail( repos = c(CRAN = getOption("minicran.mran")), type = "source" ) } else { pdb <- cranJuly2014 } if (interactive()) { dg <- makeDepGraph(tags, availPkgs = pdb , includeBasePkgs = FALSE, suggests = TRUE, enhances = TRUE) set.seed(43); plot(dg) # Move edge legend to top left set.seed(42); plot(dg, legendPosition = c(-1, 1)) # Change font size and shape size set.seed(42); plot(dg, legendPosition = c(-1, 1), vertex.size = 20, cex = 0.5) # Move vertex legend to top right set.seed(42); plot(dg, legendPosition = c(1, 1), vertex.size = 20, cex = 0.5) }
Get the path to the repo directory containing the package files.
repoPrefix(type, Rversion)
repoPrefix(type, Rversion)
type |
character, indicating the type of package to download and
install. See |
Rversion |
Version of R (only used if
|
The file path to the package files directory.
A repository has two main folders, one for source packages, and the other
for binary packages. Inside the binary package folder, bin
, you will find
subfolders for Windows as well as the various OSX binaries.
+- Root
...+- src/contrib
......+- PACKAGES
..+- bin
.......+- windows/contrib/version
..........+- PACKAGES
.......+- macosx/contrib/version
..........+- PACKAGES
.......+- macosx/mavericks/contrib/version
..........+- PACKAGES
.......+- macosx/leopard/contrib/version
..........+- PACKAGES
Not all versions of R are compatible with with all package types (e.g.,
mac.binary.el-capitan
is only valid for R > 3.4.0).
Get a two-digit version of the R version
twodigitRversion(Rversion = R.version)
twodigitRversion(Rversion = R.version)
Rversion |
Version of R (only used if
|
A character string representing the two-digit R version.
oldPackages()
indicates packages which have a (suitable) later version on
the repositories whereas updatePackages()
offers to download and install
such packages.
oldPackages( path = NULL, repos = getOption("repos"), availPkgs = pkgAvail(repos = repos, type = type, Rversion = Rversion), method, availableLocal = pkgAvail(repos = path, type = type, Rversion = Rversion, quiet = quiet), type = "source", Rversion = R.version, quiet = FALSE ) updatePackages( path = NULL, repos = getOption("repos"), method = NULL, ask = TRUE, availPkgs = pkgAvail(repos = repos, type = type, Rversion = Rversion), oldPkgs = NULL, type = "source", Rversion = R.version, quiet = FALSE )
oldPackages( path = NULL, repos = getOption("repos"), availPkgs = pkgAvail(repos = repos, type = type, Rversion = Rversion), method, availableLocal = pkgAvail(repos = path, type = type, Rversion = Rversion, quiet = quiet), type = "source", Rversion = R.version, quiet = FALSE ) updatePackages( path = NULL, repos = getOption("repos"), method = NULL, ask = TRUE, availPkgs = pkgAvail(repos = repos, type = type, Rversion = Rversion), oldPkgs = NULL, type = "source", Rversion = R.version, quiet = FALSE )
path |
Destination download path. This path is the root folder of your new repository. |
repos |
URL(s) of the 'contrib' sections of the repositories, e.g.
|
availPkgs |
Data frame with an element called |
method |
Download method, see |
availableLocal |
all packages hosted in the miniCRAN repo, as returned
by |
type |
Possible values are (currently) "source", "mac.binary" and
"win.binary": the binary types can be listed and downloaded but not
installed on other platforms. Passed to |
Rversion |
Version of R (only used if
|
quiet |
If TRUE, suppress status messages (if any), and the progress bar during download. |
ask |
logical indicating whether to ask user before packages are
actually downloaded and installed. Alternatively, the value |
oldPkgs |
if specified as non-NULL, |
These functions are based on update.packages()
. However, rather than
looking for locally installed packages they look for the package source and
binaries in the miniCRAN repository.
oldPackages()
returns a matrix with one row per package and columns
for "Package", "LocalVer", "ReposVer" and "Repository". The matrix row
names the package names.
updatePackages
returns NULL
invisibly.
Other update repo functions:
addOldPackage()
,
addPackage()
,
checkVersions()
,
makeRepo()
### `oldPackages` and `updatePackages` require an existing miniCRAN repo # Specify list of packages to download mirror <- c(CRAN = "https://cloud.r-project.org") pkgs <- c("foreach") pdb <- cranJuly2014 if (interactive()) { pdb <- pkgAvail(repos = mirror, type = "source") pkgList <- pkgDep(pkgs, availPkgs = pdb, repos = mirror, type = "source", suggests = FALSE) pkgList # Create temporary folder for miniCRAN dir.create(pth <- file.path(tempdir(), "miniCRAN")) # create the miniCRAN directory structure but only add bin files makeRepo(pkgList, path = pth, repos = mirror, type = "source", download = FALSE) makeRepo(pkgList, path = pth, repos = mirror, type = "win.binary", download = TRUE) # download old source package version and create repo index oldVers <- data.frame(package = c("foreach", "codetools", "iterators"), version = c("1.4.0", "0.2-7", "1.0.5"), stringsAsFactors = FALSE) addOldPackage(pkgList, path = pth, repos = mirror, vers = oldVers$version, type = "source") # NOTE: older binary versions would need to be build from source # Check if updated packages are available oldPackages(path = pth, repos = mirror, type = "source") # should need update oldPackages(path = pth, repos = mirror, type = "win.binary") # should be current # Update available packages updatePackages(path = pth, repos = mirror, type = "source", ask = FALSE) # should need update updatePackages(path = pth, repos = mirror, type = "win.binary") # should be current # Delete temporary folder unlink(pth, recursive = TRUE) }
### `oldPackages` and `updatePackages` require an existing miniCRAN repo # Specify list of packages to download mirror <- c(CRAN = "https://cloud.r-project.org") pkgs <- c("foreach") pdb <- cranJuly2014 if (interactive()) { pdb <- pkgAvail(repos = mirror, type = "source") pkgList <- pkgDep(pkgs, availPkgs = pdb, repos = mirror, type = "source", suggests = FALSE) pkgList # Create temporary folder for miniCRAN dir.create(pth <- file.path(tempdir(), "miniCRAN")) # create the miniCRAN directory structure but only add bin files makeRepo(pkgList, path = pth, repos = mirror, type = "source", download = FALSE) makeRepo(pkgList, path = pth, repos = mirror, type = "win.binary", download = TRUE) # download old source package version and create repo index oldVers <- data.frame(package = c("foreach", "codetools", "iterators"), version = c("1.4.0", "0.2-7", "1.0.5"), stringsAsFactors = FALSE) addOldPackage(pkgList, path = pth, repos = mirror, vers = oldVers$version, type = "source") # NOTE: older binary versions would need to be build from source # Check if updated packages are available oldPackages(path = pth, repos = mirror, type = "source") # should need update oldPackages(path = pth, repos = mirror, type = "win.binary") # should be current # Update available packages updatePackages(path = pth, repos = mirror, type = "source", ask = FALSE) # should need update updatePackages(path = pth, repos = mirror, type = "win.binary") # should be current # Delete temporary folder unlink(pth, recursive = TRUE) }