miniCRAN icon indicating copy to clipboard operation
miniCRAN copied to clipboard

pkgAvail should handle multiple package types

Open achubaty opened this issue 7 years ago • 1 comments

Managing a miniCRAN repo with multiple package types, I get the following warnings:

> updatePackages(..., type = c("mac.binary.el-capitan", "win.binary", "source"), ...)

Warning messages:
1: In if (type == "both") type <- "source" :
  the condition has length > 1 and only the first element will be used
2: In if (type == "binary") type <- .Platform$pkgType :
  the condition has length > 1 and only the first element will be used
3: In if (substr(type, 1L, 11L) == "mac.binary.") { :
  the condition has length > 1 and only the first element will be used

I think this is an issue with the use of pkgAvail -- it can only handle a single type, or both, and I can't think of an easy way to incorporate an lapply or similar into that function to deal with multiple types.

achubaty avatar Jun 19 '17 21:06 achubaty

One possibility is that pkgAvail() returns a list of matrices if length(type) . 1.

Then it becomes the responsibility of the downstream code to know how to deal with a single matrix (if type is singular) or a list (if type is plural).

You will then have to modify the lapply() loop in updatePackages() to be more like a traditional for loop:

lapply(seq_along(type), function(i){...}

Inside the ... you have to subset into type[i] and availPkgs[[i]].

andrie avatar Jun 20 '17 08:06 andrie