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

Rolf Turner r.turner at auckland.ac.nz
Sun Feb 25 11:16:54 CET 2018


Can you not, instead of

> if(pkg == "loon" && !requireNamespace("loon", quietly = TRUE))
>         stop("Package 'loon' is not available.")

do something like:

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

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.


Rolf Turner

Technical Editor ANZJS
Department of Statistics
University of Auckland
Phone: +64-9-373-7599 ext. 88276

More information about the R-package-devel mailing list