From luke-tierney at uiowa.edu  Sun Apr 10 19:54:38 2011
From: luke-tierney at uiowa.edu (luke-tierney at uiowa.edu)
Date: Sun, 10 Apr 2011 12:54:38 -0500
Subject: [Rd] Wish there were a "strict mode" for R interpreter. What
 about You?
In-Reply-To: <BANLkTi=GjefwhzQEPTojNkOWq8MT2nN82g@mail.gmail.com>
References: <BANLkTim=6ae2huv+GYQLMtgs2P+GD8_WtA@mail.gmail.com>
	<BANLkTinJO=3Epmq_2zH+3vbGmZgPp_gFGA@mail.gmail.com>
	<4DA0E592.1040507@prodsyse.com> <4DA10410.2040909@gmail.com>
	<4DA10646.6040202@structuremonitoring.com>
	<4DA1AC5C.7060005@gmail.com>
	<FFDCD3C8-D7F3-44E9-B443-7B263EB70D60@gmail.com>
	<BANLkTi=GjefwhzQEPTojNkOWq8MT2nN82g@mail.gmail.com>
Message-ID: <alpine.DEB.2.00.1104101251530.26884@luke-inspiron>

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)

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

luke

>
> Hadley
>
>
>

-- 
Luke Tierney
Statistics and Actuarial Science
Ralph E. Wareham Professor of Mathematical Sciences
University of Iowa                  Phone:             319-335-3386
Department of Statistics and        Fax:               319-335-3017
    Actuarial Science
241 Schaeffer Hall                  email:      luke at stat.uiowa.edu
Iowa City, IA 52242                 WWW:  http://www.stat.uiowa.edu


[Rd] Wish there were a "strict mode" for R interpreter. What about You?
luke-tierney at uiowa.edu