if (requireNamespace("bar", quietly = TRUE)) {
# do the good stuff
} else {
# do some less good substitute
}
without generating an error anywhere.
Hi Duncan, thanks for helping. I use the above
'::' or ':::' import not declared from: ?bar? 'loadNamespace' or 'requireNamespace' call not declared from: ?bar?
Right, you shouldn't refer to a package in code without mentioning it in the DESCRIPTION file.
This is my problem. It seems that even a *conditional* use already requires the package name to appear in DESCRIPTION. 'bar' was in Imports and I tried to submit 'foo' with 'bar' in Suggests. Both times was not accepted. I don't see how even a conditional use of 'bar' inside 'foo' is possible then. Cheers, Marius
Does this mean it is not possible to use 'bar' anymore in 'foo'?
I don't think so. But CRAN policies may have changed... Duncan Murdoch
These are (somewhat) related references I found: 1) https://cran.r-project.org/doc/manuals/r-release/R-exts.html#Suggested-packages 2) https://stat.ethz.ch/pipermail/r-devel/2013-February/065947.html