Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

R CMD check NOTE: No visible binding for global variable #850

Closed
mattdowle opened this issue Oct 2, 2014 · 3 comments
Closed

R CMD check NOTE: No visible binding for global variable #850

mattdowle opened this issue Oct 2, 2014 · 3 comments

Comments

@mattdowle
Copy link
Member

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.

@bpbond
Copy link

bpbond commented Oct 27, 2014

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

@cderv
Copy link

cderv commented Nov 9, 2016

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.

@jangorecki
Copy link
Member

jangorecki commented Nov 9, 2016

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

GregorDeCillia added a commit to statistikat/simPop that referenced this issue Dec 20, 2017
* resolve mismatch in documentation (asfactor != as_factor)
* add reshape2 to the Depends field for the ipu_step example
* Avoid 'no visible binding for global variable ...' by initializing to NULL
     V1 <- baseweight <- NULL

The last error occures since the check does not deal properly with non-standard evaluation
(NSE). See here: Rdatatable/data.table#850
jalazawa added a commit to rte-antares-rpackage/antaDraft that referenced this issue Jun 13, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants