Created
April 18, 2019 11:29
-
-
Save vjcitn/9cb7373c5fe2ee8d514260e5b9dd910c to your computer and use it in GitHub Desktop.
personal version of library that reduces information on attachment events
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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