I'm working on an R package that uses the spTransform
function in the sp
package. The rub is that this function need rgdal
loaded to work, or I get an error message:
Error in eval(expr, envir, enclos) : load package rgdal for spTransform methods
My Imports
statement in the DESCRIPTION
file includes the following:
Imports: sp,
rgdal
But I'm still getting the error. However, if I explcitly load rgdal (using library(rgdal)
) before using the package, everything works fine. I'm guessing that when my package is loaded rgdal is not attached because none of my code uses it explcitly via ::
etc.
So I think my question is: How can I make my package attach a package that I am not explicitly using?
As said by BondedDust, you need to import the required packages into your package NAMESPACE. To do so edit the file, adding a new line import(sp, rgdal). Further reading http://cran.r-project.org/doc/manuals/r-release/R-exts.html#Specifying-imports-and-exports
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