Writing package R: requires a package that I do not explicitly call

I am working on an R package that uses the spTransform function in the sp package. This function will require the rgdal function, or I get an error message:

 Error in eval(expr, envir, enclos) : load package rgdal for spTransform methods 

The My Imports statement in the DESCRIPTION file contains the following:

 Imports: sp, rgdal 

But I still get the error. However, if I explicitly load rgdal (using library(rgdal) ) before using the package, everything works fine. I assume that when my package is downloaded, rgdal is not connected, because none of my codes use it with :: , etc.

So, I think my question is: how can I make my package attached to a package that I am not explicitly using?

+7
r
source share
1 answer

As stated in BondedDust , you need to import the necessary packages into your NAMESPACE package. To do this, edit the file by 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

+7
source share

All Articles