Re: [R-pkg-devel] package dependencies not detected?

2017-08-16 Thread Dirk Eddelbuettel

On 16 August 2017 at 09:44, Duncan Murdoch wrote:
| On 16/08/2017 8:31 AM, Dirk Eddelbuettel wrote:
| >
| > On 16 August 2017 at 12:51, peter dalgaard wrote:
| > | > On 16 Aug 2017, at 11:11 , Berry Boessenkool 
 wrote:
| > | >
| > | > if a function in a package uses graphics::legend in the code, but does 
not import it in the namespace, shouldn't there be a warning in the check?
| > | >
| > |
| > | Er, no... Importing into a namespace is used to avoid the graphics:: 
qualifier. This is conceptually different from having a dependency.
| >
| > Exactly, but IIRC we get warnings on packages not listed in Suggests: which 
are
| > accessed via '::'.  And that need for a Suggests: goes away for a base 
package.
| 
| s/Suggests/Imports/g

Yes, I wasn't perfectly clear but Suggests: is what I have in a (smaller,
still local, still experimental) package where I have only

  Description: A collection of utility functions.
  Suggests: anytime, data.table, zoo, xts, TTR, quantmod

ie not a single Depends: or Imports: or LinkingTo: and all use in R/ is
prefixed by double colon.

And in that case I do not need Suggests: for base packages I use.

But yes, in the general case, one would have NAMESPACE and importFrom(...)
along with an Imports:

Dirk, who has now beaten that poor horse of Berry into utter pulp
 
| >
| > Otherwise Peter's reminder is entirely correct. You can do _either_ an
| >   importForm("graphics", "plot", "legend") in NAMESPACE (which I have done)
| > or use the explicit
| >   graphics::legend
| > you have.
| >
| > Dirk
| >
| 

-- 
http://dirk.eddelbuettel.com | @eddelbuettel | e...@debian.org

__
R-package-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-package-devel


Re: [R-pkg-devel] package dependencies not detected?

2017-08-16 Thread Duncan Murdoch

On 16/08/2017 8:31 AM, Dirk Eddelbuettel wrote:


On 16 August 2017 at 12:51, peter dalgaard wrote:
| > On 16 Aug 2017, at 11:11 , Berry Boessenkool  
wrote:
| >
| > if a function in a package uses graphics::legend in the code, but does not 
import it in the namespace, shouldn't there be a warning in the check?
| >
|
| Er, no... Importing into a namespace is used to avoid the graphics:: 
qualifier. This is conceptually different from having a dependency.

Exactly, but IIRC we get warnings on packages not listed in Suggests: which are
accessed via '::'.  And that need for a Suggests: goes away for a base package.


s/Suggests/Imports/g



Otherwise Peter's reminder is entirely correct. You can do _either_ an
  importForm("graphics", "plot", "legend") in NAMESPACE (which I have done)
or use the explicit
  graphics::legend
you have.

Dirk



__
R-package-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-package-devel


Re: [R-pkg-devel] package dependencies not detected?

2017-08-16 Thread Dirk Eddelbuettel

On 16 August 2017 at 12:51, peter dalgaard wrote:
| > On 16 Aug 2017, at 11:11 , Berry Boessenkool  
wrote:
| > 
| > if a function in a package uses graphics::legend in the code, but does not 
import it in the namespace, shouldn't there be a warning in the check?
| > 
| 
| Er, no... Importing into a namespace is used to avoid the graphics:: 
qualifier. This is conceptually different from having a dependency.

Exactly, but IIRC we get warnings on packages not listed in Suggests: which are
accessed via '::'.  And that need for a Suggests: goes away for a base package.

Otherwise Peter's reminder is entirely correct. You can do _either_ an
  importForm("graphics", "plot", "legend") in NAMESPACE (which I have done)
or use the explicit
  graphics::legend
you have.

Dirk

-- 
http://dirk.eddelbuettel.com | @eddelbuettel | e...@debian.org

__
R-package-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-package-devel


Re: [R-pkg-devel] package dependencies not detected?

2017-08-16 Thread peter dalgaard

> On 16 Aug 2017, at 11:11 , Berry Boessenkool  
> wrote:
> 
> 
> Hi,
> 
> 
> if a function in a package uses graphics::legend in the code, but does not 
> import it in the namespace, shouldn't there be a warning in the check?
> 

Er, no... Importing into a namespace is used to avoid the graphics:: qualifier. 
This is conceptually different from having a dependency.

-pd


> There is not, also not on CRAN (one of my packages did this with 
> stats::density).
> 
> Should I report this to the CRAN team?
> 
> 
> Regards,
> 
> Berry
> 
> 
> Here's a minimal working example using devtools:
> 
> ### install.packages(c("devtools","roxygen2"))
> 
> # create package structure 
> getwd()
> devtools::create("testPack", description=list(License="GPL (>=2)"))
> setwd("testPack/")
> devtools::check() # everything is fine
> 
> # add function 
> cat("
> #' @title test function
> #' @description test function
> #' @export
> #' @importFrom graphics plot
> #' @examples testFun(1:6, col=2)
> #' @param x Values
> #' @param args List of arguments passed to legend
> #' @param \\dots Further arguments passed to plot
> #'
> testFun <- function(
>  x,
>  args=list(x='topright', legend=c('A','B'), lty=1),
>  ...
>  )
>  {
>  plot(x, ...)
>  do.call(graphics::legend, args)
>  }
> ", file="R/testFun.R")
> 
> devtools::check() # no problems - even though I only import plot, not legend
> # same thing if I use graphics::legend directly (outside of do.call)
> 
> 
>   [[alternative HTML version deleted]]
> 
> __
> R-package-devel@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-package-devel

-- 
Peter Dalgaard, Professor,
Center for Statistics, Copenhagen Business School
Solbjerg Plads 3, 2000 Frederiksberg, Denmark
Phone: (+45)38153501
Office: A 4.23
Email: pd@cbs.dk  Priv: pda...@gmail.com

__
R-package-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-package-devel


Re: [R-pkg-devel] package dependencies not detected?

2017-08-16 Thread Dirk Eddelbuettel

On 16 August 2017 at 09:11, Berry Boessenkool wrote:
| if a function in a package uses graphics::legend in the code, but does not 
import it in the namespace, shouldn't there be a warning in the check?

The 'graphics' package is a base package, and as such *always* available
where R is -- see its DESCRIPTION below stating 'Priority: base'.

An explicit import would be redundant.

Dirk


Package: graphics
Version: 3.4.1
Priority: base
Title: The R Graphics Package
Author: R Core Team and contributors worldwide
Maintainer: R Core Team 
Description: R functions for base graphics.
Imports: grDevices
License: Part of R 3.4.1
NeedsCompilation: yes
Built: R 3.4.1; x86_64-pc-linux-gnu; 2017-07-08 15:13:56 UTC; unix


-- 
http://dirk.eddelbuettel.com | @eddelbuettel | e...@debian.org

__
R-package-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-package-devel