[R-pkg-devel] txt data is undefined global variable

Uwe Ligges ||gge@ @end|ng |rom @t@t|@t|k@tu-dortmund@de
Wed Jan 16 19:26:37 CET 2019



On 16.01.2019 17:00, Thierry Onkelinx wrote:
> Dear all,
> 
> I'm working on a package "foo" which has a dataframe stored in
> "data/foo.txt". The DESCRIPTION has "LazyData: true".  Functions can use
> the object "foo". e.g.

foo is not regisrered in the namespace and you are relying on search 
path order now.

If you want to have data objects you want to use in functions but which 
are not necesarily available via data() calls, use the sysdata 
mechanism. From WRE:

"if the R subdirectory contains a file sysdata.rda (a
saved image of one or more R objects: please use suitable compression as 
suggested by tools::resaveRdaFiles, and see also the 
‘SysDataCompression’ DESCRIPTION field.) this will be lazy-loaded into 
the namespace environment – this is intended for system datasets that 
are not intended to be user-accessible via data"

Best,
Uwe Ligges

> bar <- function() {
> summary(foo)
> }
> 
> However, R CMD check throws the "undefined global variable" error.
> 
> What is the proper way to use txt data in a package?
> 
> Best regards,
> 
> Thierry
> 
> ir. Thierry Onkelinx
> Statisticus / Statistician
> 
> Vlaamse Overheid / Government of Flanders
> INSTITUUT VOOR NATUUR- EN BOSONDERZOEK / RESEARCH INSTITUTE FOR NATURE AND
> FOREST
> Team Biometrie & Kwaliteitszorg / Team Biometrics & Quality Assurance
> thierry.onkelinx using inbo.be
> Havenlaan 88 bus 73, 1000 Brussel
> www.inbo.be
> 
> ///////////////////////////////////////////////////////////////////////////////////////////
> To call in the statistician after the experiment is done may be no more
> than asking him to perform a post-mortem examination: he may be able to say
> what the experiment died of. ~ Sir Ronald Aylmer Fisher
> The plural of anecdote is not data. ~ Roger Brinner
> The combination of some data and an aching desire for an answer does not
> ensure that a reasonable answer can be extracted from a given body of data.
> ~ John Tukey
> ///////////////////////////////////////////////////////////////////////////////////////////
> 
> <https://www.inbo.be>
> 
> 	[[alternative HTML version deleted]]
> 
> ______________________________________________
> R-package-devel using r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-package-devel
>



More information about the R-package-devel mailing list