[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
Wed Dec 21 10:53:14 CET 2022


@Uwe - OK, makes sense. I will read the file into an object and save it as
a .Rda in the data folder.
Thank you.
--
Sanjeev M




On Tue, Dec 20, 2022 at 2:36 PM Uwe Ligges <ligges using statistik.tu-dortmund.de>
wrote:

>
>
> On 20.12.2022 00:58, Sanjeev Sariya wrote:
> > Hi,
> > thank you for the reply.
> >
> > Do you need this to be a file? Could it be a pre-parsed R object
> > instead?
>
> Yes, and that can go into an .RData file.
>
> Best,
> Uwe Ligges
>
> >
> > 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]]
> >
> > ______________________________________________
> > R-package-devel using r-project.org mailing list
> > https://stat.ethz.ch/mailman/listinfo/r-package-devel
>

	[[alternative HTML version deleted]]



More information about the R-package-devel mailing list