packageCheck {MIfuns} | R Documentation |
packageCheck attempts to load the specified package and to run example() with the package name as an argument.
packageCheck(x,lib.loc=NULL)
x |
atomic character, the name of a single package |
lib.loc |
the library to check, passed to library() |
Many packages do not have package-level examples; the call to example() in such cases does nothing (warnings are suppressed).
an atomic character string: zero if the package does not load or if example() generates an error; otherwise, the package version.
Tim Bergsma
http://metruminstitute.org
function(x,lib.loc=NULL){ if(!is.character(x))stop("x must be character") if(length(x)!=1)stop("x must be atomic") success <- library(x,character.only=TRUE,lib.loc=lib.loc,logical.return=TRUE) if(!success){ return(0) } testResult <- try(suppressWarnings(example(x,local=TRUE))) if(inherits(testResult,"try-error")){ return(0) } return(packageDescription(x,lib.loc=lib.loc,fields="Version")) }