packageCheck {MIfuns}R Documentation

Load a package and run package-level examples for testing purposes.

Description

packageCheck attempts to load the specified package and to run example() with the package name as an argument.

Usage

packageCheck(x,lib.loc=NULL)

Arguments

x atomic character, the name of a single package
lib.loc the library to check, passed to library()

Details

Many packages do not have package-level examples; the call to example() in such cases does nothing (warnings are suppressed).

Value

an atomic character string: zero if the package does not load or if example() generates an error; otherwise, the package version.

Author(s)

Tim Bergsma

References

http://metruminstitute.org

See Also

accept, acceptance library

Examples

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"))
}

[Package MIfuns version 3.2.9 Index]