Message-ID: <0863D109-6802-4E77-97C3-6C4C0B9BBCC5@noaa.gov>
Date: 2020-02-04T18:44:52Z
From: Roy Mendelssohn - NOAA Federal
Subject: [R-pkg-devel] Suggests in a Package
In-Reply-To: <6f5254ef-04c4-bd08-af5e-2f5ae9d58e8b@gmail.com>
Thanks. And thanks for the tip.
-Roy
> On Feb 4, 2020, at 10:20 AM, Duncan Murdoch <murdoch.duncan at gmail.com> wrote:
>
> On 04/02/2020 1:13 p.m., Roy Mendelssohn - NOAA Federal via R-package-devel wrote:
>> Hi All:
>> I still get a little confused on what it means if a package is listed in "Suggest" in my package. I have been working to try and keep dependencies down. One of my packages produces maps with data, and I have been asked if the maps can be made interactive. It turns out this can be done very easily using "plotly" and I want to include something about that in the vignette. What my question is if I Suggest "plotly" in the package, does a user have to have "plotly" installed in order to install and run the package? My understanding is not, so someone who doesn't want to do this doesn't need to install "plotly" but I wanted to double-check.
>
> Your understanding is correct: someone who doesn't have plotly installed should still be able to install and run your package.
>
> You should make sure that any functions that need plotly check for it first. The recommended way to do that is to use a requireNamespace("plotly") test, e.g. something like
>
> if (requireNamespace("plotly")) {
> plotly::plotly(...)
> } else
> stop("This function requires the 'plotly' package")
>
> Your tests that use such a function should only be run if requireNamespace("plotly") returns TRUE.
>
> Duncan Murdoch
**********************
"The contents of this message do not reflect any position of the U.S. Government or NOAA."
**********************
Roy Mendelssohn
Supervisory Operations Research Analyst
NOAA/NMFS
Environmental Research Division
Southwest Fisheries Science Center
***Note new street address***
110 McAllister Way
Santa Cruz, CA 95060
Phone: (831)-420-3666
Fax: (831) 420-3980
e-mail: Roy.Mendelssohn at noaa.gov www: https://www.pfeg.noaa.gov/
"Old age and treachery will overcome youth and skill."
"From those who have been given much, much will be expected"
"the arc of the moral universe is long, but it bends toward justice" -MLK Jr.