briandk / granovaGG

Bob Pruzek and Jim Helmreich's implementation of Elemental Graphics for Analysis of Variance
Other
15 stars 4 forks source link

R CMD check produces "no visible binding for global variables" warnings #148

Closed briandk closed 12 years ago

briandk commented 12 years ago

Because in code like this:

  GroupMeansByContrast <- function(owp) {
    return( 
      geom_point( 
               aes(
                 x     = contrast, 
                 y     = group.mean, 
                 fill  = factor("Group Means")
               ),
                 size  = I(3),
                 shape = 24,
                 color = "black",
                 alpha = 0.50,
                 data  = owp$summary
      )
    )
  }

The variables contrast and group.mean aren't assigned in the function (or anywhere obvious in top-level).

Harlan Harris suggests using aes_string(): http://stackoverflow.com/a/9439360/180626

WilDoane commented 12 years ago

We had a lot of problems with ads_string()... As I recall, it defers trying to evaluate the named variable until later in the graphic construction, so we ran into scoping issues (i.e., the variable was out of scope by the time it was evaluated).

briandk commented 12 years ago

@WilDoane - good memory! I'd forgotten that.

After talking with some other developers, I was reminded that there are two categories of things R CMD check will flag:

The global binding messages we're getting are actually notes, not warnings. I missed that because there's only one line in the check output that says it, at the very top of the list of them:

* checking R code for possible problems ... NOTE
granovagg.1w: warning in jitter(stats.vc, am = ammt): partial argument
  match of 'am' to 'amount'
granovagg.1w : GetSummary: no visible binding for global variable
  'score'

Confusingly, the message about the ammt problem (easily fixed) says it's a warning in the text, but is binned as a NOTE by the check procedure.

The upshot of all this is that if we fix all the legitimate warnings, then the global binding stuff is just a NOTE, which shouldn't hold up our submission.

WilDoane commented 12 years ago

...but you also need to include a quick response to acknowledge your awareness of the note; yes?

On 2012 Feb 24, at 22:57, Brian A. Danielak wrote:

The upshot of all this is that if we fix all the legitimate warnings, then the global binding stuff is just a NOTE, which shouldn't hold up our submission.

briandk commented 12 years ago

When I resubmit later versions I may acknowledge the existence of Notes, but from all the work I've done there's simply no easy way to dispense with them, so the strategy is just going to be to tolerate them.