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

Berry Boessenkool berryboessenkool at hotmail.com
Wed Aug 16 11:11:24 CEST 2017


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?

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]]



More information about the R-package-devel mailing list