How can I check what version of R is needed for a list of packages? Ideally something like this
minimumRVersion <- function(packageList = c(), return=c("list", "min", "mine")) {
# code to collate a list of minimum versions of R
# required for the listed packages.
# Optionally return min(list) or "is my R high enough?
return(result)
}
minVersion("RcppEigen")
# 2.15.1
minVersion(c("RcppEigen","OpenMx"), "min")
# 3.0
You can use the packageDescription
function, which allows you to get package requirements.
I wrote a quick-and-dirty solution, feel free to improve on that!
minimumRVersion <- function(packageList)
{
requirements <- NULL
for (p in packageList)
{
# Get dependencies for the package
dep <- packageDescription(p, fields = "Depends")
if (!is.na(dep))
{
# dep will be something like:
# "R (>= 3.1.0), grDevices, graphics, stats, utils"
# split by comma
dep <- unlist(strsplit(dep, ","))
# Find requirement for R (may not exist)
r.dep <- dep[grep("R \\(", dep)]
if (!length(r.dep))
r.dep <- NA
}
else
r.dep <- NA
requirements <- c(requirements, r.dep)
}
requirements
}
Calling:
minimumRVersion(c("nlme", "MASS", "bootstrap", "knitr", "Hmisc"))
Returns:
[1] " R (>= 3.0.0)" "R (>= 3.1.0)" " R (>= 2.10.0)" "R (>= 3.0.2)" NA
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With