[GenABEL-dev] Fwd: CRAN packages maintained by you

Yury Aulchenko yurii.aulchenko at gmail.com
Fri Jul 3 18:03:57 CEST 2015


FYI 

----------------
Sent from mobile device, please excuse possible typos

Begin forwarded message:

> From: Kurt Hornik <Kurt.Hornik at wu.ac.at>
> Date: 2 Jul 2015 11:28:45 CEST
> To: CRAN at R-project.org
> Subject: CRAN packages maintained by you
> Reply-To: Kurt.Hornik at wu.ac.at
> 
> 
> Dear CRAN package maintainers,
> 
> You may already have seen the following news item for r-devel:
> 
>    * 'R CMD check --as-cran' now checks code usage (via 'codetools')
>      with only the base package attached, so that functions from
>      default packages other than base which are used in the package
>      code but not imported are reported as undefined globals.
> 
> This may result in lots of notes about undefined globals which can be
> found in the default packages.  The change was made because even though
> the default packages (stats, graphics, ...) are typically loaded and
> attached, bindings not found in the package code itself, the imports or
> base are searched for along the search path starting with the global
> environment, and there is no control over what is actually found there.
> Therefore, undefined globals corresponding to functions or variables in
> the default packages, really need to be imported into the package
> namespace.
> 
> With current versions of r-devel, one can get a convenient summary of
> all undefined globals, which can be used for programmatically generating
> the missing imports as follows.  
> 
> One package currently gives
> 
> * checking R code for possible problems ... NOTE
> choose_palette : SaveColorsToFile: no visible global function
>  definition for ‘write.table’
> choose_palette : ShowExample: no visible global function definition for
>  ‘dev.list’
> choose_palette : ShowExample: no visible global function definition for
>  ‘dev.new’
> choose_palette : ShowExample: no visible global function definition for
>  ‘dev.cur’
> choose_palette : ShowExample: no visible global function definition for
>  ‘par’
> choose_palette : RegenExample: no visible global function definition
>  for ‘dev.list’
> choose_palette : RegenExample: no visible global function definition
>  for ‘dev.set’
> choose_palette : PlotMap: no visible global function definition for
>  ‘polygon’
> <...................................................................>
> choose_palette : PlotMosaic: no visible global function definition for
>  ‘image’
> choose_palette : PlotLines: no visible global function definition for
>  ‘segments’
> choose_palette: no visible global function definition for
>  ‘compareVersion’
> choose_palette: no visible global function definition for ‘dev.list’
> choose_palette: no visible global function definition for ‘dev.off’
> desaturate: no visible global function definition for ‘col2rgb’
> Undefined global functions or variables:
>  barplot col2rgb compareVersion cutree dev.cur dev.list dev.new
>  dev.off dev.set dist dnorm hclust head image na.omit par persp pie
>  polygon rect rnorm runif segments volcano write.table
> 
> Using the above output, do
> 
> txt <- "barplot col2rgb compareVersion cutree dev.cur dev.list dev.new
>  dev.off dev.set dist dnorm hclust head image na.omit par persp pie
>  polygon rect rnorm runif segments volcano write.table"
> 
> and use
> 
> imports_for_undefined_globals <-
> function(txt, lst, selective = TRUE)
> {
>    if(!missing(txt))
>        lst <- scan(what = character(), text = txt, quiet = TRUE)
>    nms <- lapply(lst, find)
>    ind <- sapply(nms, length) > 0L
>    imp <- split(lst[ind], substring(unlist(nms[ind]), 9L))
>    if(selective) {
>        sprintf("importFrom(%s)",
>                vapply(Map(c, names(imp), imp),
>                       function(e)
>                           paste0("\"", e, "\"", collapse = ", "),
>                       ""))
>    } else {
>        sprintf("import(\"%s\")", names(imp))
>    }
> }                       
> 
> to get
> 
> R> writeLines(imports_for_undefined_globals(txt))
> importFrom("datasets", "volcano")
> importFrom("grDevices", "col2rgb", "dev.cur", "dev.list", "dev.new", "dev.off", "dev.set")
> importFrom("graphics", "barplot", "image", "par", "persp", "pie", "polygon", "rect", "segments")
> importFrom("stats", "cutree", "dist", "dnorm", "hclust", "na.omit", "rnorm", "runif")
> importFrom("utils", "compareVersion", "head", "write.table")
> 
> For non-selective importing, use
> 
> R> writeLines(imports_for_undefined_globals(txt, selective = FALSE))
> import("datasets")
> import("grDevices")
> import("graphics")
> import("stats")
> import("utils")
> 
> Of course, namespaces newly imported from also need to be listed in the
> Imports: field of DESCRIPTION.
> 
> Please make sure you make the necessary changes before you submit new
> versions of your package to CRAN.
> 
> Best
> -k
> 
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.r-forge.r-project.org/pipermail/genabel-devel/attachments/20150703/16e28d17/attachment.html>


More information about the genabel-devel mailing list