I had my R-package using RDCOMClient via DESCRIPTION file:
Suggests: RDCOMClient
and the following (perfectly working) code:
GetNewWrd <- function() {
stopifnot(require(RDCOMClient))
# Starts the Word application with wrd as handle
wrd <- RDCOMClient::COMCreate("Word.Application", existing=FALSE)
newdoc <- wrd[["Documents"]]$Add("",FALSE, 0)
wrd[["Visible"]] <- TRUE
invisible(wrd)
}
Nowadays this seems to be considered as bad practice and "Writing R Extensions, 1.1.3.1 Suggested packages" tells us to formulate:
if (requireNamespace("rgl", quietly = TRUE)) {
rgl::plot3d(...)
} else {
## do something else not involving rgl.
}
or: .. If the intention is to give an error if the suggested package is not available, simply use e.g. rgl::plot3d.
Recoding this (to my understanding) would mean, just to delete the require-statement:
GetNewWrd <- function() {
# Starts the Word application with wrd as handle
wrd <- RDCOMClient::COMCreate("Word.Application", existing=FALSE)
newdoc <- wrd[["Documents"]]$Add("",FALSE, 0)
wrd[["Visible"]] <- TRUE
invisible(wrd)
}
Doing this leads to the following runtime error:
Error in RDCOMClient::COMCreate("Word.Application", existing = FALSE) :
could not find function "createCOMReference"
createCOMReference is a function in RDCOMClient, which apparently can't be found without the explicit require statement.
How for God's sake am I supposed to integrate RDCOMClient in my package complying to CRAN's policies???