[R-pkg-devel] Dependencies in DESCRIPTION: Imports vs. Suggests

Joris Meys Jori@@Mey@ @ending from ugent@be
Mon Nov 19 21:18:04 CET 2018


Dear Paul,

the correct form is something like:

if( requireNamespace("abind", quietly = TRUE) )
{  abind::foo() # do sth with abind} else {
    message("you need to install the pkg abind for this example")
}

In general you should avoid sending out code that installs packages. Some
people work with specific versions of packages and don't want them
overwritten by a call to install.packages(). Others use specific libraries
on their computer instead of the default. The CRAN requirements are there
to protect people from unexpected changes to their setup.

Cheers
Joris

On Mon, Nov 19, 2018 at 9:04 PM Paul Hargarten <hargartenp using mymail.vcu.edu>
wrote:

> Hi all,
>
> I am relatively new in creating R packages. I have created a new package
> called *"foo"* and submitted it to CRAN for review.
> I am wondering the difference between "Imports" and "Suggests" dependencies
> in DESCRIPTION file.  According to my understanding, the "Imports" field
> contains all packages required for my functions to work; the "suggests"
> field contains packages that* foo* uses but doesn't require them.
> Programmers
> place these suggested packages to run examples, to run tests, and build
> vignettes, according to Hadley Wickham (also see
>   <http://r-pkgs.had.co.nz/description.html
> <http://r-pkgs.had.co.nz/description.html> >).  I think that this field
> exists to limit the user the burden of downloading extra packages.
>
> As suggested packages are not installed, I should add the following line in
> examples that use this package. For instance,* abind* was listed as a
> suggested package for *foo;* so I should add this line anywhere before I
> use any functions in *abind. *
> *      > if( !requireNamespace("abind", quietly = TRUE) )
> {  install.packages("abind")}*
>
> But I got an error from CRAN that I should not install packages in the
> examples. I suppose that these packages should be in the "Import" field in
> DESCRIPTION file. But, I am confused why that would be the case given that
> these packages were used in the examples only and not in any functions in
> *foo. *
>
> Thus, I am wondering how you decide which packages are suggested compared
> to
>  imported.
>
>
> --
> Paul Hargarten, M.S.
> PhD Candidate
> Biostatistics,  VCU School of Medicine
> Biochemistry and Molecular Biology, B.S.;  Chemistry, B.A. ; Mathematics,
> minor
> hargartenp using vcu.edu
>
>         [[alternative HTML version deleted]]
>
> ______________________________________________
> R-package-devel using r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-package-devel
>


-- 
Joris Meys
Statistical consultant

Department of Data Analysis and Mathematical Modelling
Ghent University
Coupure Links 653, B-9000 Gent (Belgium)
<https://maps.google.com/?q=Coupure+links+653,%C2%A0B-9000+Gent,%C2%A0Belgium&entry=gmail&source=g>

tel: +32 (0)9 264 61 79
-----------
Biowiskundedagen 2017-2018
http://www.biowiskundedagen.ugent.be/

-------------------------------
Disclaimer : http://helpdesk.ugent.be/e-maildisclaimer.php

	[[alternative HTML version deleted]]



More information about the R-package-devel mailing list