When writing a package in R, is it necessary to add base packages (utils, grDevices, stats, etc.) as dependencies in the DESCRIPTION
of your package?
Some packages do this, but most seem to not.
I have not found any information in the Writing R Extensions manual regarding this.
You should not set too much dependencies but prefer to use those packages as import :
for instance in the DESCRIPTION you will write
Imports:
graphics,
utils,
stats,
grDevices
In your NAMESPACE you can then use either importFrom, in the case you only have a few functions to use. Then you don't have to point to the function using pkg::fun(), or import pkg which will import the whole package, and again you will not need to use the pkg::fun().
Below an example of what you can write in your NAMESPACE
import(graphics)
importFrom(stats,coef)
importFrom(stats,ftable)
importFrom(stats,na.fail)
importFrom(utils,data)
importFrom(utils,globalVariables)
importFrom(utils,read.csv)
importFrom(utils,select.list)
importFrom(utils,stack)
importFrom(utils,write.table)
If you try to use those functions without importing them or use depends, the R-CMD check will fail.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With