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

From: peter dalgaard <pdalgd_at_gmail.com>
Date: Sun, 10 Apr 2011 18:18:09 +0200

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:

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

______________________________________________
R-devel_at_r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel
Received on Sun 10 Apr 2011 - 16:21:13 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Sun 10 Apr 2011 - 18:00:43 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-devel. Please read the posting guide before posting to the list.

list of date sections of archive