Skip to content
Prev 57682 / 63424 Next

improving the performance of install.packages

On 08/11/2019 2:06 a.m., Joshua Bradley wrote:
Whether or not they'd do it, it's easy for you to do it.

install.packages <- function(pkgs, ..., force = FALSE) {
   if (!force) {
     pkgs <- Filter(Negate(requireNamespace), pkgs

   utils::install.packages(pkgs, ...)
}

You might want to make this more elaborate, e.g. doing update.packages() 
on the ones that exist.  But really, isn't the problem with the script 
you're using, which could have done a simple test before forcing a slow 
install?

Duncan Murdoch