Skip to content

[R-pkg-devel] no visible global function definition for ‘par’

12 messages · Cathy Lee Gierke, Brian G. Peterson, Kasper Daniel Hansen +4 more

#
Yes, that seemed to get rid of the NOTE....but it doesn't seem to make much
difference other than that.  i.e., it seems to process the same using
CATkit vs CATkit_2.06.tar.gz!

Here is the main error that I am getting.  I just upgraded to the latest R
version, fyi.

Everything was fine, a few minor warnings...now this.  Description and
namespace are proper.  These pkgs should all be part of the R base, aren't
they? Anyone know why I should get these errors?  Thanks!

* checking R code for possible problems ... NOTE

Actogram: no visible global function definition for ?par?

Actogram: no visible global function definition for ?barplot?

Actogram: no visible global function definition for ?box?

Actogram: no visible global function definition for ?text?

Actogram: no visible global function definition for ?mtext?

Actogram: no visible binding for global variable ?end?

AutoCorr: no visible global function definition for ?par?

AutoCorr: no visible global function definition for ?layout?

AutoCorr: no visible global function definition for ?acf?

AutoCorr: no visible global function definition for ?abline?

AutoCorr: no visible global function definition for ?title?

AutoCorr: no visible global function definition for ?mtext?

AutoCorr: no visible global function definition for ?var?

AutoCorr: no visible binding for global variable ?end?

CATCosinor: no visible global function definition for ?par?

CATCosinor: no visible global function definition for ?pdf?

CATCosinor: no visible global function definition for ?jpeg?

CATCosinor: no visible global function definition for ?png?

CATCosinor: no visible global function definition for ?tiff?

......... A zillion more for every function I have......

periCosinor: no visible global function definition for ?par?

periCosinor: no visible global function definition for ?fft?

Undefined global functions or variables:

  TukeyHSD abline acf aov as.raster axis barplot box boxplot ccf

  coefficients dev.cur dev.off drop1 end fft gray heat.colors image

  jpeg layout legend lines median model.tables mtext na.action na.omit

  palette par pdf pf plot plot.new png points rainbow rasterImage

  read.table str strwidth tail terrain.colors text tiff title ts var

  write.table

Consider adding

  importFrom("grDevices", "as.raster", "dev.cur", "dev.off", "gray",

             "heat.colors", "jpeg", "palette", "pdf", "png", "rainbow",

             "terrain.colors", "tiff")

  importFrom("graphics", "abline", "axis", "barplot", "box", "boxplot",

             "image", "layout", "legend", "lines", "mtext", "par",

             "plot", "plot.new", "points", "rasterImage", "strwidth",

             "text", "title")

  importFrom("stats", "TukeyHSD", "acf", "aov", "ccf", "coefficients",

             "drop1", "end", "fft", "median", "model.tables",

             "na.action", "na.omit", "pf", "ts", "var")

  importFrom("utils", "read.table", "str", "tail", "write.table")

to your NAMESPACE file.

Cathy Lee Gierke


*?Darkness cannot drive out darkness: only light can do that. Hate cannot
drive out hate: only love can do that.? *
*?The arc of the moral universe is long, but it bends towards justice.?*
*?Nothing in the world is more dangerous than sincere ignorance and
conscientious stupidity.? *
*?Never forget that everything Hitler did in Germany was legal.?   *
*?Forgiveness is not an occasional act, it is a constant attitude.? *
*?Injustice anywhere is a threat to justice everywhere.?  *

? Martin Luther King Jr.

<http://www.goodreads.com/author/show/23924.Martin_Luther_King_Jr_>

On Mon, Jan 30, 2017 at 10:05 AM, Brian G. Peterson <brian at braverock.com>
wrote:

  
  
#
On 30 January 2017 at 10:39, Cathy Lee Gierke wrote:
| Everything was fine, a few minor warnings...now this.  Description and
| namespace are proper.  These pkgs should all be part of the R base, aren't
| they? Anyone know why I should get these errors?  Thanks!

Just read what it says and do that:

| Consider adding
| 
|   importFrom("grDevices", "as.raster", "dev.cur", "dev.off", "gray",
|              "heat.colors", "jpeg", "palette", "pdf", "png", "rainbow",
|              "terrain.colors", "tiff")
|   importFrom("graphics", "abline", "axis", "barplot", "box", "boxplot",
|              "image", "layout", "legend", "lines", "mtext", "par",
|              "plot", "plot.new", "points", "rasterImage", "strwidth",
|              "text", "title")
|   importFrom("stats", "TukeyHSD", "acf", "aov", "ccf", "coefficients",
|              "drop1", "end", "fft", "median", "model.tables",
|              "na.action", "na.omit", "pf", "ts", "var")
|   importFrom("utils", "read.table", "str", "tail", "write.table")
| 
| to your NAMESPACE file.

Dirk
#
The error you reference below is pretty clear, I think.
You need to add imports for all the functions you're using from other
packages.??
See: https://cran.r-project.org/doc/manuals/r-release/R-exts.html#Speci
fying-imports-and-exports
Regards,
Brian
On Mon, 2017-01-30 at 10:39 -0600, Cathy Lee Gierke wrote:
--?
Brian G. Peterson
http://braverock.com/brian/
Ph: 773-459-4973
IM: bgpbraverock
#
That is the obvious solution, but it doesn't seem correct:  I have pdf
included in the description, and namespace files, yet it is being called
out.  Additionally, aren't most of these pkgs in the packages included by
default?

And up until yesterday, I didn't have any of these problems.  I've been
compiling and running this for several years.  But now I want to release to
CRAN, so I've been fixing minor issues....and suddenly this mass of Notes.

Thank you,

Cathy Lee Gierke


*?Darkness cannot drive out darkness: only light can do that. Hate cannot
drive out hate: only love can do that.? *
*?The arc of the moral universe is long, but it bends towards justice.?*
*?Nothing in the world is more dangerous than sincere ignorance and
conscientious stupidity.? *
*?Never forget that everything Hitler did in Germany was legal.?   *
*?Forgiveness is not an occasional act, it is a constant attitude.? *
*?Injustice anywhere is a threat to justice everywhere.?  *

? Martin Luther King Jr.

<http://www.goodreads.com/author/show/23924.Martin_Luther_King_Jr_>

On Mon, Jan 30, 2017 at 10:52 AM, Brian G. Peterson <brian at braverock.com>
wrote:

  
  
#
See the link in my email below.??It says:
"Packages implicitly import the base namespace. Variables exported from
other packages with namespaces need to be imported explicitly using the
directives?import?and?importFrom."

Regards,

Brian
On Mon, 2017-01-30 at 11:04 -0600, Cathy Lee Gierke wrote:
#
On Mon, Jan 30, 2017 at 12:04 PM, Cathy Lee Gierke <leegi001 at umn.edu> wrote:

            
No, they are not. Read the documentation and see the error

And up until yesterday, I didn't have any of these problems.  I've been
I have no idea what you did previously to ignore this. But the
behaviour/error you see is always caused by an incomplete NAMESPACE; its
very common.

Perhaps follow the advice from all the other replies.

Best,
Kasper

  
  
#
Most importantly, this _is_ a recent-ish change in R CMD check. Previously,
R CMD check did not warn about missing imports from 'base' R packages (that
is, R packages distributed with R, having priority 'base'); now it
correctly does. While packages with priority 'base' are loaded by default
in most R installations, it's possible for the user to customize that
behavior, and so packages that don't import the functions they use from
these packages will break if they are detached (or their order on the
search path is changed).

The correct thing to do is indeed import any functions from any R packages
you use, base or otherwise. The simplest fix, if you don't want to
selectively import such a large range of functions, is to simply add e.g.

    import(utils)
    import(stats)
    ... etc ...

to your NAMESPACE file.

Best,
Kevin

On Mon, Jan 30, 2017 at 9:21 AM, Brian G. Peterson <brian at braverock.com>
wrote:

  
  
#
On 30/01/2017 12:04 PM, Cathy Lee Gierke wrote:
For several years R would allow functions from base packages to be 
assumed to be on the search list, but it no longer does so (and hasn't 
since R 3.3.0).  This is a good thing:  if your user says library(foo), 
and the foo package happens to export a pdf() function, your package may 
end up using that one, even though you really mean grDevices::pdf().  If 
you explicitly import pdf() from grDevices, that won't happen.

Duncan Murdoch
#
Thank you. That will be why I didn't see them previously. Helps my sanity ;-)

Sent from my iPhone

  
  
#
On 30 January 2017 at 09:58, Kevin Ushey wrote:
| The correct thing to do is indeed import any functions from any R packages
| you use, base or otherwise. The simplest fix, if you don't want to
| selectively import such a large range of functions, is to simply add e.g.
| 
|     import(utils)
|     import(stats)
|     ... etc ...
| 
| to your NAMESPACE file.

Or do what R CMD check suggested and import the ones used, rather than all.

Which is what I had quoted earlier:

| Consider adding
| 
|   importFrom("grDevices", "as.raster", "dev.cur", "dev.off", "gray",
|              "heat.colors", "jpeg", "palette", "pdf", "png", "rainbow",
|              "terrain.colors", "tiff")
|   importFrom("graphics", "abline", "axis", "barplot", "box", "boxplot",
|              "image", "layout", "legend", "lines", "mtext", "par",
|              "plot", "plot.new", "points", "rasterImage", "strwidth",
|              "text", "title")
|   importFrom("stats", "TukeyHSD", "acf", "aov", "ccf", "coefficients",
|              "drop1", "end", "fft", "median", "model.tables",
|              "na.action", "na.omit", "pf", "ts", "var")
|   importFrom("utils", "read.table", "str", "tail", "write.table")
| 
| to your NAMESPACE file.

I find this preferable and quite appreciate that R CMD check provides it.

Dirk
#

        
> On 30 January 2017 at 09:58, Kevin Ushey wrote:
> | The correct thing to do is indeed import any functions from any R packages
    > | you use, base or otherwise. The simplest fix, if you don't want to
    > | selectively import such a large range of functions, is to simply add e.g.
    > | 
    > |     import(utils)
    > |     import(stats)
    > |     ... etc ...
    > | 
    > | to your NAMESPACE file.

    > Or do what R CMD check suggested and import the ones used, rather than all.

    > Which is what I had quoted earlier:

    > | Consider adding
    > | 
    > |   importFrom("grDevices", "as.raster", "dev.cur", "dev.off", "gray",
    > |              "heat.colors", "jpeg", "palette", "pdf", "png", "rainbow",
    > |              "terrain.colors", "tiff")
    > |   importFrom("graphics", "abline", "axis", "barplot", "box", "boxplot",
    > |              "image", "layout", "legend", "lines", "mtext", "par",
    > |              "plot", "plot.new", "points", "rasterImage", "strwidth",
    > |              "text", "title")
    > |   importFrom("stats", "TukeyHSD", "acf", "aov", "ccf", "coefficients",
    > |              "drop1", "end", "fft", "median", "model.tables",
    > |              "na.action", "na.omit", "pf", "ts", "var")
    > |   importFrom("utils", "read.table", "str", "tail", "write.table")
    > | 
    > | to your NAMESPACE file.

    > I find this preferable and quite appreciate that R CMD check provides it.
    > Dirk

yes, and that is not only Dirk :

It *is* highly preferable and recommended, also in *the*
reference manual ("Writing R Extensions", aka WRE) for reasons
of
  - efficiency,
  - modularity and "self-documentation"
  - much better control against accidental name clashes,

There are very few exceptions where importing a whole namespace
makes sense and the above base packages are typically never part
of these exceptions.

Martin Maechler
ETH Zurich and R Core
#
Thank you.  Makes sense.  It is *very* helpful to have R CMD check provide
that.

Cathy Lee Gierke


*?Darkness cannot drive out darkness: only light can do that. Hate cannot
drive out hate: only love can do that.? *
*?The arc of the moral universe is long, but it bends towards justice.?*
*?Nothing in the world is more dangerous than sincere ignorance and
conscientious stupidity.? *
*?Never forget that everything Hitler did in Germany was legal.?   *
*?Forgiveness is not an occasional act, it is a constant attitude.? *
*?Injustice anywhere is a threat to justice everywhere.?  *

? Martin Luther King Jr.

<http://www.goodreads.com/author/show/23924.Martin_Luther_King_Jr_>

On Tue, Jan 31, 2017 at 2:17 AM, Martin Maechler <maechler at stat.math.ethz.ch