Since the latest R update I get the Note
summary.xmlImport: no visible global function definition for ‘median’
in the CRAN check. Further notes refer to read.table
, write.table
and other standard functions in R.
When I have a look on my file summary.xmlImport, the file looks like this:
summary.xmlImport <- function(object, ...){
rowCount <- sapply(object,nrow)
cat("Summary of xmlImport object\n")
cat("---------------------------\n")
cat("Sequences :",length(object),"\n")
cat("Min hits :",min(rowCount),"\n")
cat("Average hits :",mean(rowCount),"\n")
cat("Median hits :",median(rowCount),"\n")
cat("Max hits :",max(rowCount),"\n")
invisible(object)
}
I cannot understand, why I should add now the median
function to the NAMESPACE, but why not the min
, mean
, etc. The note is only about the median
function.
Anybody an idea what the reason for the Note is and how to fix it? I noted that there are tons of R packages that have currently the same Note.
I can understand this warning in the context of a non-declared variable, but I would assume that median()
, read.table()
and such functions are globally visible in R, especially as mean()
seems to be!?
EDIT: I only receive the Note on CRAN, but not on my local computer what makes the search for the solution a bit nasty... The session info of my computer:
> sessionInfo()
R version 3.2.1 (2015-06-18)
Platform: x86_64-pc-linux-gnu (64-bit)
Running under: Ubuntu 14.04.2 LTS
As of Monday June 29, 2015, all non-base functions must be explicitly exported in NAMESPACE in order to pass R CMD check --as-cran
. The change comes because code is now checked with only the base package attached, so functions from default packages (such as stats) must be listed explicitly.
To import these packages, consider doing the following:
Imports
. There is very little reason to ever list a package in Depends
.import(stats)
or importFrom(stats, ...)
, where ...
is one or more comma-separated function names. (If you use roxygen2::roxygenize()
or devtools::document()
to generate documentation and NAMESPACE, the analogous markup would be #' @import stats
and #' @importFrom stats ...
.)If you want to work interactively with R in a mode that mimics this, you'll want to start R with only the base package attached. There are several ways to do this, but probably the easiest is to set an environment variable at your shell: R_DEFAULT_PACKAGES=NULL
or in the .Renviron file and then start R using R --vanilla
. In Terminal or bash this would be:
$ export R_DEFAULT_PACKAGES=NULL
$ R --quiet --vanilla
> search()
[1] ".GlobalEnv" "Autoloads" "package:base"
In Windows command prompt it would be:
C:\>SET R_DEFAULT_PACKAGES=NULL
C:\>R --quiet --vanilla
> search()
[1] ".GlobalEnv" "Autoloads" "package:base"
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With