[Rd] Wish there were a "strict mode" for R interpreter. What about You?

peter dalgaard pdalgd at gmail.com
Sun Apr 10 20:11:11 CEST 2011


On Apr 10, 2011, at 19:54 , <luke-tierney at uiowa.edu> wrote:

> On Sun, 10 Apr 2011, Hadley Wickham wrote:
> 
>>>> Okay, I understand what you are trying to do.  Yes, you have fooled codetools in this instance.
>>> 
>>> ...but notice that the codetools warning is just that: It _is_ acknowledged that these things occasionally happen by design. There are a couple of cases in base R too:
>>> 
>>> * checking R code for possible problems ... NOTE
>>> glm.fit: no visible binding for global variable ‘n’
>> 
>> Are you sure that's not a bug?  There's:
>> 
>> aic.model <- aic(y, n, mu, weights, dev) + 2 * rank
>> 
>> and n.ok is defined, but n isn't defined anywhere.
> 
> It is (or should be) defined by the call to
> 
>        eval(family$initialize)
> 

...iff actually used by family$aic. And, it is a different n from n.ok (a vector, the per-element size parameter of the binomial)



>> 
>>> quantile.ecdf: no visible binding for global variable ‘y’
>> 
>> I wonder why it warns on y, but not nobs.
> 
> It does when run on stats:::quantile.ecdf directly:
> 
>> codetools::checkUsage(stats:::quantile.ecdf)
> <anonymous>: no visible binding for global variable ‘nobs’
> <anonymous>: no visible binding for global variable ‘y’
> 
> Maybe in the context where you saw this nobs is defined in an
> enclosing environment.
> 

It came from make check-devel, so I suspect that it picks up stats:::nobs() (which would be horribly wrong, but, well...)


> luke
> 
>> 
>> Hadley

-- 
Peter Dalgaard
Center for Statistics, Copenhagen Business School
Solbjerg Plads 3, 2000 Frederiksberg, Denmark
Phone: (+45)38153501
Email: pd.mes at cbs.dk  Priv: PDalgd at gmail.com



More information about the R-devel mailing list