[R-pkg-devel] Referring to data in R/sysdata.rda
Spencer Graves
spencer.graves at effectivedefense.org
Sat Apr 15 18:38:57 CEST 2017
On 2017-04-15 11:24 AM, Hadley Wickham wrote:
> Just ignore it.
> Hadley
>
> On Friday, April 14, 2017, Roy Mendelssohn - NOAA Federal <
> roy.mendelssohn at noaa.gov> wrote:
>
>> In my package I have a dataframe that I use but want to hide from the
>> user. In Hadley's book on R Packages, he says:
>>
>>> • If you want to store parsed data, but not make it available to
>> the user, put it in R/sysdata.rda. This is the best place to put data that
>> your functions need.
>> I have done that, and sure enough when the package is loaded, the
>> structure is there. However, when I am working on debugging code, and I
>> refer to the structure in a function, RStudio gives a warning that the
>> structure is out of scope, say the data frame is myDF:
>>
>> myFunc <- function(myIndex) {
>> junk <- myDF[index]
>> return(junk)
>> }
Have you tried the following:
> myFunc <- function(myIndex) {
> junk <- yrPkg:::myDF[index]
> return(junk)
> }
This will turn of similar messages is slightly different
contexts. I don't know if it will work here (and I don't have time to
try it myself now). Spencer Graves
>> RStudio will warn that myDF is out of scope. My question is if there is a
>> proper way to refer to myDF so as not to get the warning, or just ignore
>> it. Basically before submission I try to remove all warnings from the
>> editor, even style ones, just to have things cleaner.
>>
>> Thanks,
>>
>> -Roy
>>
>>
>>
>>
>>
>> **********************
>> **********************
>> "The contents of this message do not reflect any position of the U.S.
>> Government or NOAA."
>> **********************
>> Roy Mendelssohn
>> Supervisory Operations Research Analyst
>> NOAA/NMFS
>> Environmental Research Division
>> Southwest Fisheries Science Center
>> ***Note new street address***
>> 110 McAllister Way
>> Santa Cruz, CA 95060
>> Phone: (831)-420-3666
>> Fax: (831) 420-3980
>> e-mail: Roy.Mendelssohn at noaa.gov <javascript:;> www:
>> http://www.pfeg.noaa.gov/
>>
>> "Old age and treachery will overcome youth and skill."
>> "From those who have been given much, much will be expected"
>> "the arc of the moral universe is long, but it bends toward justice" -MLK
>> Jr.
>>
>> ______________________________________________
>> R-package-devel at r-project.org <javascript:;> mailing list
>> https://stat.ethz.ch/mailman/listinfo/r-package-devel
>
>
More information about the R-package-devel
mailing list