Colin Gillespie <csgillespie at gmail.com>
on Mon, 10 Aug 2015 20:33:32 +0000 writes:
Dear All,
I have a package that uses reference classes. When I build the package I
get numerous notes of the sort
Note: no visible binding for '<<-' assignment to 'pars'
I've tried using GlobalVariables, but that didn't solve the issue.
[ You mean globalVariables(): and it's a bad idea anyway IMO,
even if it is recommended : If you declare a variable in
there, it is "global" in all places in your package and the
codetools won't report it anywhere anymore.
Much better in my view is to use something like
var7 <- NULL # ~= globalVariables("var7")
]
To your question:
Reference classes are used in *many* places, and the use of ' <<- '
is really "standard" there.
e.g., package 'lme4', or 'pcalg' are two packages I'm involved with,
which use ref.classes and ' <<- ' but are "fine" with that.
So there must be something peculiar in your package leading to
the <<- warnings.
Maybe you should look into the source code of such other CRAN
packages to see how "they" do it differently than you.
Best regards,
Martin
Martin Maechler, ETH Zurich
After some googling, I came across the page
http://stackoverflow.com/q/23475309/203420 which suggests
suppressBindingNotes <- function(variablesMentionedInNotes) {
for(variable in variablesMentionedInNotes) {
assign(variable,NULL, envir = .GlobalEnv)
}
}
suppressBindingNotes(c("dat", "internal", "xmin", "pars", "no_pars"))
But checking the package with --as-cran raises the note
* checking R code for possible problems ... NOTE
Found the following assignments to the global environment:
File ?poweRlaw/R/aaa_all_classes.R?:
assign(variable, NULL, envir = .GlobalEnv)
What is the correct way of removing the "visible bindings" notes?
Thanks
Colin
[[alternative HTML version deleted]]