[Rd] no visible binding for global variable

From: Max Kuhn <mxkuhn_at_gmail.com>
Date: Thu, 05 Feb 2009 14:53:40 -0500


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)     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.



> sessionInfo()

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


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

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

R-devel_at_r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel Received on Thu 05 Feb 2009 - 19:55:46 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Thu 05 Feb 2009 - 20:30:20 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-devel. Please read the posting guide before posting to the list.

list of date sections of archive