[R-pkg-devel] How do I enable to show data in inst/extdata in data() || lazy load

Sanjeev Sariya @@njeev@@r|y@ @end|ng |rom gm@||@com
Tue Dec 20 00:58:49 CET 2022


Hi,
thank you for the reply.

Do you need this to be a file? Could it be a pre-parsed R object
instead?


I need to provide an external data/file in the R package. This has come as
a request from F1000 journal editors.

One way to solve this could be to write a script that imports the file
from inst/extdata using the facilities provided by your package and put
it in a file under data/, then document the resulting object.


What do you call this step? How do I do this?
I thought to loading the file as lazyload, .onload package something?

Best,
--
Sanjeev M




On Tue, Dec 20, 2022 at 1:55 AM Ivan Krylov <krylov.r00t using gmail.com> wrote:

> On Mon, 19 Dec 2022 20:59:27 +0530
> Sanjeev Sariya <sanjeevsariya using gmail.com> wrote:
>
> > ... I have created a .Rd file.
> > I'm interested in listing this file in data() ...
>
> My understanding is that data() is for R-level objects, and so is
> help(), most likely.
>
> One way to solve this could be to write a script that imports the file
> from inst/extdata using the facilities provided by your package and put
> it in a file under data/, then document the resulting object. I think
> that if you build your package with --no-resave-data, it will remain an
> R script that will be run during the data() call. (By default, your R
> script will be run during R CMD build and its output will be packaged
> into a gzip-compressed RData file.)
>
> This might go against the guidance at
> <https://cran.r-project.org/doc/manuals/R-exts.html#Data-in-packages>,
> which says:
>
> >> R code should be if possible “self-sufficient” and not make use of
> >> extra functionality provided by the package, so that the data file
> >> can also be used without having to load the package or its namespace
>
> Do you need this to be a file? Could it be a pre-parsed R object
> instead?
>
> --
> Best regards,
> Ivan
>

	[[alternative HTML version deleted]]



More information about the R-package-devel mailing list