[Rd] no visible binding for global variable

Max Kuhn mxkuhn at gmail.com
Thu Feb 5 20:53:40 CET 2009


Everyone,

I know that this has been discussed a few times on the list, but I
think that there is a high false positive rate of messages from
findGlobals during R CMD check (I know the help page has that "The
result is an approximation").

Here are two examples of from the caret package:

This function get the message "predictors.gbm: no visible binding for
global variable 'rel.inf'"

predictors.gbm <- function(x, ...)
  {
    library(gbm)
    varList <- if(hasTerms(x)) predictors(x$terms) else colnames(x$data$x.order)
    relImp <- summary(x, plotit = FALSE)
    varUsed <- as.character(subset(relImp, rel.inf != 0)$var)
    basicVars(varList, varUsed)
  }

So it didn't take the context into account that subset isn't
(necessarily) looking in the global environment.

Also, the package has a file splsda.R that has the message
"splsda.default: no visible binding for global variable 'ncomp'". The
oddness of this one is that there is no variable named ncomp
explicitly mentioned in the file (confirmed by grep and I checked that
the function wasn't accidentally defined twice).

In fairness, this function has caught little issues in my code that
could have led to issues, so I'm certainly not implying that it is
ineffective. Looking through the page with package check results,
there are a lot of packages with these types of notes and it makes me
wonder how many of them are real issues. Of course they are only
notes, but the extra verboseness might make people not pay as much
attention when a big issues arises.

Thanks

Max


> sessionInfo()
R version 2.9.0 Under development (unstable) (2009-01-22 r47686)
i386-apple-darwin9.6.0

locale:
en_US.UTF-8/en_US.UTF-8/C/C/en_US.UTF-8/en_US.UTF-8

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base

other attached packages:
[1] codetools_0.2-1



More information about the R-devel mailing list