Skip to content

[Bioc-devel] Question about package dependency

3 messages · Xu Ren, Shepherd, Lori, Vincent Carey

#
Hi everyone,

I'm developing a Bioconductor package and I have a question about package
dependency. The functions in my package do not depend on ggplot2 but I used
ggplot2 to do some visualization in the package vignette. I'm wondering if
I should import ggplot2 in the DESCRIPTION file. If ggplot2 is not
imported, R CMD check will produce a note:


* checking tests ...

  Running ?testthat.R?

 OK

* checking for unstated dependencies in vignettes ... NOTE

'library' or 'require' call not declared from: ?ggplot2?

* checking package vignettes in ?inst/doc? ... OK

* checking running R code from vignettes ...

If ggplot2 is imported, since it is used only in the vignette, and none of
the function in my package depend on ggplot2, R CMD check generates another
note:

* checking loading without being on the library search path ... OK

* checking dependencies in R code ... NOTE

Namespace in Imports field not imported from: ?ggplot2?

  All declared Imports should be used.

* checking S3 generic/method consistency ... OK

* checking replacement functions ... OK



So I'm wondering if ggplot2 should be imported in this case. Thank you!

Sincerely,
Xu Ren
#
I believe this type of dependency belongs in the Suggests:  field of the DESCRIPTION file.


Lori Shepherd

Bioconductor Core Team

Roswell Park Cancer Institute

Department of Biostatistics & Bioinformatics

Elm & Carlton Streets

Buffalo, New York 14263
#
put ggplot2 in Suggests:

see 1.1.3 of https://cran.r-project.org/doc/manuals/r-release/R-exts.html

The ?Suggests? field uses the same syntax as ?Depends? and lists packages
that are not necessarily needed. This includes packages used only in
examples, tests or vignettes (see Writing package vignettes
<https://cran.r-project.org/doc/manuals/r-release/R-exts.html#Writing-package-vignettes>),
and packages loaded in the body of functions. E.g., suppose an example11
<https://cran.r-project.org/doc/manuals/r-release/R-exts.html#FOOT11> from
package *foo* uses a dataset from package *bar*. Then it is not necessary
to have *bar* use *foo* unless one wants to execute all the
examples/tests/vignettes: it is useful to have *bar*, but not necessary.
Version requirements can be specified but should be checked by the code
which uses the package.
On Tue, Feb 19, 2019 at 10:02 AM Xu Ren <xuren2120 at gmail.com> wrote: