I am trying to create a package for the first time and am having trouble with R CMD check.
Initially, I was getting "notes" saying that there was no visible binding for my global variables. I added assignments to those variables at the top of the file being checked and now when the examples run, I get errors saying that I cannot change the value of a locked binding. Since I am not locking the bindings, I assume this is something that R CMD check is doing, but I have been unable to find any documentation describing what this means or how to fix it.
Here is a specific example. My R file includes a function like this:
.ddg.init.tables <- function() {
size <- 100
ddg.proc.nodes <<- data.frame(ddg.type = character(size),
ddg.num = numeric(size), ddg.name = character(size),
ddg.value = character(size), stringsAsFactors=FALSE)
}
With the function defined like this, I would get the note:
.ddg.init.tables: no visible binding for '<<-' assignment to 'ddg.proc.nodes'
To resolve this, I added above the definition of .ddg.init.tables:
ddg.proc.nodes <- NULL
The note went away, but later in the R CMD check process when checking the examples, while running the line from the example:
ddg.init()
I now get the error:
> ddg.init()
Error in .ddg.init.tables() :
cannot change value of locked binding for 'ddg.proc.nodes'
Calls: ddg.init -> .ddg.init.tables
Execution halted
If I leave out the initialization, I get the note, but the example executes.
What is the meaning of the "locked binding" message and what is the best way to fix it?
Thanks for your help.