From pdalgd at gmail.com  Sun Apr 10 18:18:09 2011
From: pdalgd at gmail.com (peter dalgaard)
Date: Sun, 10 Apr 2011 18:18:09 +0200
Subject: [Rd] Wish there were a "strict mode" for R interpreter. What
	about You?
In-Reply-To: <4DA1AC5C.7060005@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>
Message-ID: <FFDCD3C8-D7F3-44E9-B443-7B263EB70D60@gmail.com>


On Apr 10, 2011, at 15:10 , Duncan Murdoch wrote:

> On 11-04-09 9:22 PM, Spencer Graves wrote:
>> On 4/9/2011 6:12 PM, Duncan Murdoch wrote:
>>> On 11-04-09 7:02 PM, Spencer Graves wrote:
....
>>>> 
>>>>         "R CMD check" will give this message sometimes when I don't feel
>>>> it's appropriate.  For example, I define a data object ETB in a package,
>>>> then give that as the default in a function call like
>>>> f(data.=ETB){if(missing(data.))data(ETB);  data.}.  When I run "R CMD
>>>> check", I get "no visible binding for global variable 'ETB'", even
>>>> though the function is tested and works during R CMD check.
>>> 
>>> What is ETB?  Your code is looking for a global variable by that name,
>>> and that's what codetools is telling you.
>> 
>> Duncan:  Thanks for the question.
>> 
>> 
>> ETB is a data object in my package.  codetools can't find it because
>> data(ETB) is needed before ETB becomes available.  codetools is not
>> smart enough to check to see if ETB is a data object in the package.
> 
> 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?
quantile.ecdf: no visible binding for global variable ?y?

I can't seem to spot the 'n' just now, though...

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



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