Fixed return of list_depends to be a bit nicer for basic users but more detailed for those that need it (including this package)
This commit is contained in:
@@ -3,7 +3,7 @@
|
||||
allPackages <- installed.packages()
|
||||
allPackages <- as.data.frame(allPackages)
|
||||
packages <- allPackages[allPackages$Package %in% packages,]
|
||||
packages <- allPackages[,c("Package", "Version", "Imports")]
|
||||
packages <- packages[,c("Package", "Version", "Imports")]
|
||||
packages$Imports <- gsub(packages$Imports, pattern = "\n", replacement = " ")
|
||||
packages$Imports <- strsplit(packages$Imports, ", ")
|
||||
packages <- data.frame(
|
||||
@@ -31,9 +31,22 @@
|
||||
#' packages.
|
||||
#'
|
||||
#' @param packages A character vector of packages to find dependencies of
|
||||
#' @param fullTree A boolean to select the return type (See details)
|
||||
#'
|
||||
#' The fullTree parameter can be used to provide only the packages and versions
|
||||
#' required to re-build an environment of dependencies for the provided packages
|
||||
#' or a table capable of being used to construct a full dependency tree.
|
||||
#'
|
||||
#' @return A data frame with the dependency tree
|
||||
#' @export
|
||||
list_depends <- function(packages) {
|
||||
.list_depends(packages, gen = 0)
|
||||
list_depends <- function(packages, fullTree = FALSE) {
|
||||
depends <- .list_depends(packages, gen = 0)
|
||||
if (fullTree) {
|
||||
return(depends)
|
||||
}
|
||||
depends <- depends[,c("package", "version")]
|
||||
depends <- unique(depends)
|
||||
depends <- depends[sort(depends$package, index.return = TRUE)$ix,]
|
||||
row.names(depends) <- 1:nrow(depends)
|
||||
return(depends)
|
||||
}
|
||||
@@ -5,10 +5,16 @@
|
||||
\title{Recursively find all the installed dependencies of one or more installed
|
||||
packages.}
|
||||
\usage{
|
||||
list_depends(packages)
|
||||
list_depends(packages, fullTree = FALSE)
|
||||
}
|
||||
\arguments{
|
||||
\item{packages}{A character vector of packages to find dependencies of}
|
||||
|
||||
\item{fullTree}{A boolean to select the return type (See details)
|
||||
|
||||
The fullTree parameter can be used to provide only the packages and versions
|
||||
required to re-build an environment of dependencies for the provided packages
|
||||
or a table capable of being used to construct a full dependency tree.}
|
||||
}
|
||||
\value{
|
||||
A data frame with the dependency tree
|
||||
|
||||
Reference in New Issue
Block a user