Re: [Rd] R CMD check returns NOTE about package data set as global variable

From: peter dalgaard <pdalgd_at_gmail.com>
Date: Fri, 06 Apr 2012 22:04:21 +0200

On Apr 6, 2012, at 21:33 , Brad McNeney wrote:

> OK, thanks for the tip on good coding practice. I'm still getting the NOTE though when I make the suggested change.

Hm? It's not like Brian to get such things wrong, did you check properly?

Perhaps the code checker is not smart enough to know that data() creates global variables. (That would be heuristic at best. You can't actually be sure that data() creates objects with the name given as the argument -- in fact, several objects might be created, possibly none named as the argument).

You are not using LazyData, right? You might consider doing that and forgetting about data() entirely.

> In case it matters, I'm check'ing with
> 
> R version 2.15.0 (2012-03-30)
> Platform: i386-pc-mingw32/i386 (32-bit)
> 
> Brad
> 
> ----- Original Message -----
>> From: "Prof Brian Ripley" <ripley_at_stats.ox.ac.uk>
>> To: "Brad McNeney" <mcneney_at_sfu.ca>
>> Cc: r-devel_at_r-project.org
>> Sent: Friday, 6 April, 2012 12:18:14 PM
>> Subject: Re: [Rd] R CMD check returns NOTE about package data set as global variable
>> 
>> On 06/04/2012 19:46, Brad McNeney wrote:

>>> I'm developing a package that comes with a data set called
>>> RutgersMapB36. One of the package's functions requires this data
>>> frame. A toy example is:
>>>
>>> test<-function() {
>>> data(RutgersMapB36)
>>> return(RutgersMapB36[,1])
>>> }
>>>
>>>
>>> R CMD check returns a NOTE:
>>>
>>> test: no visible binding for global variable 'RutgersMapB36'
>>>
>>> Is there any way to avoid this NOTE?
>> 
>> Use data("RutgersMapB36"), which many think is good practice in code.
>> 
>> 

>>>
>>> Thanks,
>>>
>>> Brad
>>> ---
>>> Brad McNeney
>>> Statistics and Actuarial Science
>>> Simon Fraser University
>>>
>>> ______________________________________________
>>> R-devel_at_r-project.org mailing list
>>> https://stat.ethz.ch/mailman/listinfo/r-devel
>> 
>> 
>> --
>> Brian D. Ripley,                  ripley_at_stats.ox.ac.uk
>> Professor of Applied Statistics,  http://www.stats.ox.ac.uk/~ripley/
>> University of Oxford,             Tel:  +44 1865 272861 (self)
>> 1 South Parks Road,                     +44 1865 272866 (PA)
>> Oxford OX1 3TG, UK                Fax:  +44 1865 272595
>> 
> 
> ______________________________________________
> R-devel_at_r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-devel

-- 
Peter Dalgaard, Professor,
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 Fri 06 Apr 2012 - 20:06:15 GMT

This quarter's messages: by month, or sorted: [ by date ] [ by thread ] [ by subject ] [ by author ]

All messages

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 Fri 06 Apr 2012 - 20:40:41 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