Closed djhocking closed 9 years ago
Yeah, I can never figure out what the Writing R Packages manual is saying. So when in doubt, look at one of hadley wickhams' packages. I just looked at tidyr and in his DESCRIPTION
the only thing under Depends
is the R version. Then all the packages used by the library are under Imports
.
Then in the source code, he never actually calls require()
or library()
so I think as long as the packages are listed under Imports
in DESCRIPTION
then they get loaded automatically.
But I think its supposed to be good practice to namespace the functions used from other packages with ::
. Like if you wanted to use the ggplot()
function from ggplot2
then you would write ggplot2::ggplot()
in the source code. This specifies that ggplot
comes from ggplot2
. See Line 31 of gather.R
where he uses dplyr::select_vars
but never calls library(dplyr)
.
I've read a few things recently that might be helpful. I actually started looking into this because I had an issue with calling specific versions of packages, not really about imports/depends. But, they cover that.
http://obeautifulcode.com/R/How-R-Searches-And-Finds-Stuff/ http://stackoverflow.com/questions/8637993/better-explanation-of-when-to-use-imports-depends
The first link is incredibly thorough. Sections I've read so far have been helpful; a thorough read-through is on my to-do list.
All that being said, I'm current using Depends... the word I'm currently using in my DESCRIPTION file uses the word "Depends". Works fine for now, but I'll gladly change that if consensus moves in that direction.
Thanks, Ana
When checking the package I get the following warning
I don't (can't) modify NAMESPACE because it is automatically generated by
roxygen2
. I tried reading the Writing R packages manual but am not clear what to put inDepends
and then if those are needed inlibrary()
orrequire()
calls within functions.http://cran.r-project.org/doc/manuals/r-release/R-exts.html#Package-Dependencies
Should I be using
Imports
instead ofDepends
?