I'm wondering if its possible to suppress these outputs in R which are cluttering up the console:
Note: no visible binding for global variable '.->ConfigString'
Note: no visible binding for '<<-' assignment to 'ConfigString'
Here is the code (its a simple ReferenceClass to store configuration for an R project):
# Reference Class to store configuration
Config <- setRefClass("Config",
fields = list(
ConfigString = "character"
),
methods = list(
# Constructor
initialize = function() {
ConfigString <<- "Hello, World!"
}
)
)
What I have tried so far
I've tried ever combination and permutation of predefining the variables, pre-setting them to null, etc, but R is still stubbornly printing hundreds of "No Visible Binding" notes in my source code.
Is anyone wiser than I when it comes to the internals of R?
Update 1
I've tried changing Config <-
to Config <<-
, and that gets rid of the second extraneous note. The first extraneous note is still present, however.
Update 2
I'm beginning to lose heart, even sample code by John Chambers generates more of these horrible, extraneous notes.
Update 3
These notes occur in Revolution R v7.0, but don't occur in RStudio. It appears as if Revolution R v7.0 is calling R CMD check
, which is normally only used when preparing packages, so these notes can safely be ignored.
Update 4
Hadley Wickhams code also generates these notes. Apparently, it is possible to eliminate them using utils::globalVariables
, however, this doesn't seem to work on the newer ReferenceClasses. Even if it were at all possible to use them, Hadley states:
globalVariables is a hideous hack and I will never use it.
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…