Skip to content

Commit

Permalink
Updated package.dependencies in reproInfo
Browse files Browse the repository at this point in the history
  • Loading branch information
Derek Ogle committed Feb 13, 2016
1 parent 9ee6f0a commit 91d444c
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 22 deletions.
1 change: 1 addition & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
* `histFromSum()`: Added. Addresses [#4](https://github.com/droglenc/FSA/issues/4).
* `metaM()`: Modified. Changed order of methods in `methods=`. Minor corrections and additions to documentation.
* `mrClosed()`: Modified. Now sends warning if an `NA` appears in the first position of `m`, the first position of `M`, or the last position of `R` and converts these to 0 so that the procedure can continue. Each of these positions is ignored in the calculations. This fixes [#8](https://github.com/droglenc/FSA/issues/8) (Thanks to Joe Mrnak).
* `reproInfo()`: Modified. Made changes to `iGetAllDependencis()` based on forthcoming changes to `package.dependencies()` (as notified by CRAN).
* `vbStarts()`: Modified. Fixed bug when `dynamicPlot=TRUE` was used.


Expand Down
32 changes: 10 additions & 22 deletions R/knitUtil.R
Original file line number Diff line number Diff line change
Expand Up @@ -195,30 +195,18 @@ iMakeFilename <- function(file,extension,directory=NULL) {
}

iGetAllDependencies <- function(pkgs) {
# get a list of available packages ... this is needed for package.dependencies below
inst <- utils::installed.packages()
# isolate to the supplied packages
inst <- inst[inst[,"Package"] %in% pkgs,]
deps <- NULL
# a catch if there is only one package
if (is.vector(inst)) n <- 1
else n <- nrow(inst)
# must cycle through provided packages
for (i in 1:n) {
# get dependent packages for ith provided package
d <- tools::package.dependencies(inst,,"Depends")[[i]]
# handles those with no dependent packages
if (is.matrix(d)) deps <- c(deps,d[,1])
# ditto for imported paxckages
d <- tools::package.dependencies(inst,,"Imports")[[i]]
if (is.matrix(d)) deps <- c(deps,d[,1])
## Check if repository has been set
if ("@CRAN@" %in% options("repos")$repos && interactive()) {
cat(gettext("--- Please select a CRAN mirror for this session ---"),"\n",sep="")
utils::flush.console()
utils::chooseCRANmirror()
}
# remove "R" if it is listed as a dependent
deps <- deps[deps!="R"]
# remove names attribute
## Get a list of packages that pkgs depends on
deps <- tools::package_dependencies(pkgs,utils::available.packages(),
which=c("Depends","Imports"))
## remove list, sort, and remove names attribute
deps <- sort(unlist(deps))
attr(deps,"names") <- NULL
# alphabetize
deps <- sort(deps)
# return original list and dependents
unique(c(pkgs,deps))
}
Expand Down

0 comments on commit 91d444c

Please sign in to comment.