ices-tools-prod / icesTAF

Functions to support the ICES Transparent Assessment Framework
GNU General Public License v3.0
5 stars 7 forks source link

option to unload all packages #14

Closed colinpmillar closed 4 years ago

colinpmillar commented 4 years ago

This would be to clean out all packages before running a script. There are a bunch of occurances of functions being masked by other packages, such as raster::select and dpyr::select

Something like this could be useful:

detachAllPackages <- function() {
  basic.packages <- 
  c("package:stats", "package:graphics", "package:grDevices", 
     "package:utils", "package:datasets", "package:methods", "package:base")
  package.list <- search()[ifelse(unlist(gregexpr("package:", search())) == 1, TRUE, FALSE)]
  package.list <- setdiff(package.list, basic.packages)
  if (length(package.list) > 0) {
    for (package in package.list) 
      detach(package, character.only = TRUE)
  }
}
colinpmillar commented 4 years ago

We might think about adding an optiong to sourceTAF(taf = TRUE) and sourceAll(taf = TRUE) a bit like cran = TRUE in the check packages functions in devtools. If taf = TRUE it would mimic what is done on the server and clears out all the folders, unloads packages etc.

arni-magnusson commented 4 years ago

Implemented in 8a8731e.