Skip to content
Prev 2444 / 12125 Next

[R-pkg-devel] [FORGED] Re: How to (conditionally) use an archived package (without Suggests)?

Marius:

Can you not, instead of
do something like:

if(pkg == "loon" && !requireNamespace("loon", quietly = TRUE)) {
         cat("Package 'loon' is not available.\n")
         cat("Sorry 'bout that, chief!\n")
         return(invisible())
}

Thereby no error is thrown.  The user may be unhappy with the result,
but he or she would have been similarly unhappy with the error, and
there is no way of constructing your function so that such a user *will* 
be happy.

cheers,

Rolf Turner