Skip to content

Instantly share code, notes, and snippets.

@vjcitn
Created April 18, 2019 11:29
Show Gist options
  • Save vjcitn/9cb7373c5fe2ee8d514260e5b9dd910c to your computer and use it in GitHub Desktop.
Save vjcitn/9cb7373c5fe2ee8d514260e5b9dd910c to your computer and use it in GitHub Desktop.
personal version of library that reduces information on attachment events
libstats = function(inisess, newsess) {
inibase = inisess$basePkgs
inioth = names(inisess$otherPkgs)
newbase = newsess$basePkgs
newoth = names(newsess$otherPkgs)
iniatt = length(unique(c(inibase,inioth)))
newatt = length(unique(c(newbase,newoth)))
addatt = newatt-iniatt
inilo = names(inisess$loadedOnly)
newlo = names(newsess$loadedOnly)
addlo = length(setdiff(newlo, inilo))
c(addatt=addatt, addlo=addlo)
}
library = function(...) {
inisess = sessionInfo()
suppressPackageStartupMessages({
libdata = base::library(...)
newsess = sessionInfo()
lstats = libstats(inisess=inisess, newsess=newsess)
message(sprintf("%d/%d packages newly attached/loaded, see sessionInfo() for details.", lstats["addatt"], lstats["addlo"]))
invisible(NULL)
})
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment