Especially if packages are recently archived, they can usually be installed from source without a problem.
I've been meaning to write this helper function for a little while:
- go to CRAN archive page for the package
- find the most recent/last version of the package (I'm not sure this will work perfectly if the package versions are such that they are sorted inconsistently in alphabetical order ...)
- construct the location of the 'tarball' (compressed source archive)
- install
If the package has compiled components you'll need to have development tools installed.
This is very much like remotes::install_version()
but (1) it finds the latest archived version automatically (2) you don't need to install the remotes
package.
install_last_archived <- function(pkg, verbose = TRUE) {
arch_url <- "https://cran.r-project.org/src/contrib/Archive/"
rr <- readLines(paste0(arch_url, pkg))
last <- tail(rr[grepl(pkg,rr)],1)
tarball <- gsub(sprintf(".*(%s_[0-9.]*\\.tar\\.gz).*", pkg), "\\1", last)
if (verbose) cat("installing ", tarball, "\n")
install.packages(paste0(arch_url, pkg, "/", tarball), repos = NULL)
}
install_last_archived("YieldCurve")
Possible enhancements: (1) work harder to make sure we have the most recent version (check dates explicitly?) (2) extract the DESCRIPTION
file to see if the package has compiled components, if so then warn user ...