[R] Display warning when embedded data file is loaded

Martin Morgan mtmorgan at fhcrc.org
Mon Jan 9 18:25:44 CET 2012


On 01/09/2012 12:38 AM, Hintzen, Niels wrote:
> Dear all,
>
> I didn't manage to get any new insights on this, anyone from the list suggestions?

Hi Niels --

Files in the data directory of a package can be an R script, so in 
PkgA/data/f.R

   f <- local({
       message("curves ahead")
       1:5
   })

This requires that the package be built with, e.g.,

   R CMD build --no-resave-data PkgA

or with the system environment variable _R_BUILD_RESAVE_DATA_=no defined.

Martin



>
> Best regards,
>
> Niels Hintzen
>
> -----Original Message-----
> From: r-help-bounces at r-project.org [mailto:r-help-bounces at r-project.org] On Behalf Of Hintzen, Niels
> Sent: maandag, januari 02, 2012 10:42
> To: r-help at r-project.org
> Subject: [R] Display warning when embedded data file is loaded
>
> Dear all,
>
> I would like to show a warning when a data file, that is embedded in the package, is loaded. I have so far not been able to find any manual or mailing list going on about that.
>
> In code example:
>
> library("myPackage")
> data("myData")
>   # Now I want a warning containing info about this loaded 'myData' file
>
> It would be great if someone could indicate if this is at all possible, and if so, how to embed it (or where I can read how to do it).
>
> Many thanks in advance,
>
> Niels
>
> ______________________________________________
> R-help at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>
> ______________________________________________
> R-help at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.


-- 
Computational Biology
Fred Hutchinson Cancer Research Center
1100 Fairview Ave. N. PO Box 19024 Seattle, WA 98109

Location: M1-B861
Telephone: 206 667-2793



More information about the R-help mailing list