From hpages at fhcrc.org  Fri Apr  6 22:23:01 2012
From: hpages at fhcrc.org (=?ISO-8859-1?Q?Herv=E9_Pag=E8s?=)
Date: Fri, 06 Apr 2012 13:23:01 -0700
Subject: [Rd] R CMD check returns NOTE about package data set as global
 variable
In-Reply-To: <1114888490.18258021.1333740833420.JavaMail.root@jaguar9.sfu.ca>
References: <1114888490.18258021.1333740833420.JavaMail.root@jaguar9.sfu.ca>
Message-ID: <4F7F50A5.7090304@fhcrc.org>

On 04/06/2012 12:33 PM, 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.

Because when you do return(RutgersMapB36[,1]), the code checker has no
way to know that the RutgersMapB36 variable is actually defined.

Try this:

test<-function() {
    RutgersMapB36 <- NULL
    data(RutgersMapB36)
    return(RutgersMapB36[,1])
}

Cheers,
H.

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


-- 
Herv? Pag?s

Program in Computational Biology
Division of Public Health Sciences
Fred Hutchinson Cancer Research Center
1100 Fairview Ave. N, M1-B514
P.O. Box 19024
Seattle, WA 98109-1024

E-mail: hpages at fhcrc.org
Phone:  (206) 667-5791
Fax:    (206) 667-1319



[Rd] R CMD check returns NOTE about package data set as global variable
=?ISO-8859-1?Q?Herv=E9_Pag=E8s?=