Data.table: R CMD check NOTE: No visible binding for global variable

Created on 2 Oct 2014  ·  3Comments  ·  Source: Rdatatable/data.table

Packages using data.table (and I believe dplyr as well) get this NOTE (perhaps many) from R CMD check. Is there anything we can do? It is only a NOTE so can be ignored, but even so.

Perhaps provide a function that detects those symbols and creates the globalVariables() call automatically for the package author.

http://stackoverflow.com/questions/15409806/r-package-compilation-with-dependency-on-data-table
http://stackoverflow.com/questions/8096313/no-visible-binding-for-global-variable-note-in-r-cmd-check

IIUC, it would need a change to 'R CMD check' to make it aware of "non-standard-evaluation" that both data.table and dplyr use. That is a hard problem (perhaps even impossible without running the code). So functions ?globalVariables was added to R in 2.15.1 and lesser known perhaps is that ?dontCheck was added in R 3.1.0 which can be used to wrap queries using NSE. These are better than <-NULL which has the risk of silencing true errors (or perhaps creating new ones) in other areas of the code, as well as the ones using NSE.

Most helpful comment

@cderv you can just assign NULL to the variable before using it (not confuse with override it). So you are not defining global variables, but just defining them locally in a function where you are using them. I don't think we need to address that in any special way. Closing for now as the issue is waiting for 2 years without action points defined, and isn't really a data.table issue.

All 3 comments

Can't necessarily be ignored; some packages are being rejected, and authors being told by CRAN to use globalVariables to suppress the NOTEs. E.g.:

http://stackoverflow.com/questions/9439256/how-can-i-handle-r-cmd-check-no-visible-binding-for-global-variable-notes-when#comment20826625_12429344

Hi,
it is an old issue but not closed. I was wondering if there is now a new solution ?
Otherwise, what is the good practice to follow ? still globalVariables ?

I like the idea of

a function that detects those symbols and creates the globalVariables()

Thank you.

@cderv you can just assign NULL to the variable before using it (not confuse with override it). So you are not defining global variables, but just defining them locally in a function where you are using them. I don't think we need to address that in any special way. Closing for now as the issue is waiting for 2 years without action points defined, and isn't really a data.table issue.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

jameslamb picture jameslamb  ·  3Comments

alex46015 picture alex46015  ·  3Comments

andschar picture andschar  ·  3Comments

DavidArenburg picture DavidArenburg  ·  3Comments

nachti picture nachti  ·  3Comments