Reputation: 2323
I am about to release an R package, but I am having trouble with the messages that are printed to the R console when the package is loaded in R. My package depends on several other packages, and these other packages display various welcome and startup messages. This is because I added the packages to the Depends
field in the DESCRIPTION
file rather than the Imports
field. My understanding is that using the Imports
field would suppress the startup messages. However, if I import the packages rather than depend on them, my examples in the help files no longer work because some functions in these packages, which are used by other functions in the same packages which are in turn used by functions I am using in my package code, cannot be found. What can I do to suppress the dozens of lines of messages without importing them (that is, by having them in the Depends
field)? Or, alternatively, how can I make sure the functions are all available when I import them? Does the problem occur because the functions which are indirectly needed are not exported by the package in question? It does not seem to work even if I import the problematic functions explicitly...
Edit - more details: A function in my package calls the ergmMPLE()
function in the ergm
package. So I have added Imports: ergm
to the DESCRIPTION
file and import("ergm")
to the NAMESPACE
file. When I use the function in my package, I get an error message that the function check.control.class
could not be found by the ergmMPLE
function. So I looked up this function and it appears to be located in yet another package called statnet.common
. Therefore I added statnet.common
to the Imports
field in the DESCRIPTION
file as well and added import("statnet.common")
to the NAMESPACE
file. Now it looks like the ergmMPLE
function still does not find the check.control.class
function. My solution would be to just let my package depend on the statnet.common
package, but then I have the problem with the startup messages again...
Upvotes: 3
Views: 406
Reputation: 60944
You can put the packages in the Import
part and load the necessary functions from the other packages using import
or importForm
. For more details see:
Upvotes: 1