[R] "no visible binding for global variable" and with() vs. within()

Daniel Braithwaite contact.dtb at gmail.com
Sun Aug 17 03:36:39 CEST 2014

R CMD check does not object to this code when checking a package:

foo1 <- function (bar) {
    with(bar, {
        x })

but produces a warning:

foo2: no visible binding for global variable 'x'

in response to this:

foo2 <- function (bar) {
    within(bar, {
        x })

Is this an R bug, or at least, an inadvertent inconsistency?  Here is
sessionInfo() from my machine, right after starting an interactive session:

R version 3.1.1 (2014-07-10)
Platform: x86_64-apple-darwin10.8.0 (64-bit)

[1] en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base

	[[alternative HTML version deleted]]

More information about the R-help mailing list