RDCOMClient is offered in a package
I had an R package using RDCOMClient via DESCRIPTION file:
Offers: RDCOMClient
and the following (working perfectly) 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)
}
This seems to be considered bad practice at present, and "Writing R Extensions, 1.1.3.1 Suggested Packages" tells us to state:
if (requireNamespace("rgl", quietly = TRUE)) {
rgl::plot3d(...)
} else {
## do something else not involving rgl.
}
or: .. If the intent is to give an error if the suggested package is not available, just use eg. RGL :: Plot3D.
Re-coding this (to my understanding) would simply mean removing the request-assertion:
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 so results in the following runtime error:
Error in RDCOMClient::COMCreate("Word.Application", existing = FALSE) :
could not find function "createCOMReference"
createCOMReference is a function in RDCOMClient that apparently cannot be found without an explicit require.
How, luckily, I have to integrate RDCOMClient into my CRAN compliant package.
+3
source to share
No one has answered this question yet
Check out similar questions: