On Tue, Oct 22, 2013 at 8:03 PM, Marc Girondot <marc_...@yahoo.fr> wrote: > Dear list members: > > I try to check my updated package to include a new version in CRAN > (phenology) but a new error is indicated and I don't find the logic. > First my system: > * using R version 3.0.2 Patched (2013-09-27 r64011) > * using platform: x86_64-apple-darwin10.8.0 (64-bit) > > Here is the message: > > * checking dependencies in R code ... NOTE > Packages in Depends field not imported from: > ‘fields’ ‘zoo’ > These packages needs to imported from for the case when > this namespace is loaded but not attached. > See the information on DESCRIPTION files in the chapter ‘Creating R > packages’ of the ‘Writing R Extensions’ manual.
Just as packages under 'Imports:' in your DESCRIPTION file need to have corresponding import()/importFrom() statements in the NAMESPACE file, so do packages under 'Depends:'. That is what this 'R CMD check' NOTE is trying to say. If you don't do this, those package's functions/variables will only be available if you *attach* your package, but not if you only *load* it. That's also what the NOTE tries to say. When you do library()/require(), you *attach* a package and it appear in the search() path and all functions/variables in the search() path will be found by the user and from all packages attached/loaded. When a package is *loaded* - explicitly via loadNamespace()/requireNamespace(), but more commonly via Imports: statements in DESCRIPTION, it is *not* attached to the search() path and therefore none of its functions/variables are found. Such functions/variables are only found if they are explicitly imported via import()/importFrom() in the NAMESPACE file. Most people will *attach* your package, i.e. library("YourPackage"), and currently the functions/variables of the packages under "Depends:" will be on the search() and therefore found by the functions of your package. To see what packages are attached (=on the search() path) and which are only loaded, look as sessionInfo(). So far so, good. However, if someone else decides to use one of your package's functions in their package and put it under 'Imports:", e.g. Package: AnotherPackage Depends: SomePackage Imports: YourPackage <= your package you will be in trouble. Because, library("AnotherPackage") will *attach* AnotherPackage and SomePackage to the search() path and *load* YourPackage. In turn, you have specified in your DESCRIPTION will *load* all packages under its "Imports:" as well as "Depends:". However, since your NAMESPACE file does not import()/importFrom() any of the packages under "Depends:", none of those functions will be found. Your functions will give errors like 'could not find function "foo". Basically, "Depends:" could be though of as "AttachOrLoad:" and "Imports:" as "LoadOnly:". To learn more about how all this works and why/why not, I strongly recommend Suraj Gupta's nice write up 'How R Searches and Finds Stuff' (Mar 2012): http://obeautifulcode.com/R/How-R-Searches-And-Finds-Stuff/ /Henrik > > It is based on this line in DESCRIPTION file: > Depends: fields, zoo, coda, R (>= 2.14.0) > > I use indeed functions from fields and zoo packages. > > If I create a new line: > Imports: fields, zoo > and remove these two packages from depends, I have still a problem in > Imports and errors because functions from fields and zoo are not available. > * checking dependencies in R code ... NOTE > Namespaces in Imports field not imported from: > ‘fields’ ‘zoo’ > All declared Imports should be used. > See the information on DESCRIPTION files in the chapter ‘Creating R > packages’ of the ‘Writing R Extensions’ manual. > * checking R code for possible problems ... NOTE > .read_phenology: no visible global function definition for ‘na.locf’ > plot.phenologymap: no visible global function definition for > ‘image.plot’ > > > If I add the packages fields, zoo packages in both Depends and Imports, I > have also error because packages fields, zoo are indicated twice and I have > the same errors as previously indicated. > * checking DESCRIPTION meta-information ... NOTE > Packages listed in more than one of Depends, Imports, Suggests, Enhances: > ‘fields’ ‘zoo’ > A package should be listed in only one of these fields. > > Of course I read ‘Creating R packages’ of the ‘Writing R Extensions’ manual, > but I can't find solution to this problem. > > Thanks a lot, > > Marc Girondot > > -- > __________________________________________________________ > Marc Girondot, Pr > > Laboratoire Ecologie, Systématique et Evolution > Equipe de Conservation des Populations et des Communautés > CNRS, AgroParisTech et Université Paris-Sud 11 , UMR 8079 > Bâtiment 362 > 91405 Orsay Cedex, France > > Tel: 33 1 (0)1.69.15.72.30 Fax: 33 1 (0)1.69.15.73.53 > e-mail: marc.giron...@u-psud.fr > Web: http://www.ese.u-psud.fr/epc/conservation/Marc.html > Skype: girondot > > ______________________________________________ > R-help@r-project.org mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide http://www.R-project.org/posting-guide.html > and provide commented, minimal, self-contained, reproducible code. ______________________________________________ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.