[Rd] no visible binding for global variable
mxkuhn at gmail.com
Thu Feb 5 20:53:40 CET 2009
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, ...)
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)
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.
R version 2.9.0 Under development (unstable) (2009-01-22 r47686)
attached base packages:
 stats graphics grDevices utils datasets methods base
other attached packages:
More information about the R-devel