[R] R code in RData

Martin Maechler m@ech|er @end|ng |rom @t@t@m@th@ethz@ch
Thu Oct 28 17:15:37 CEST 2021


>>>>> Jeff Newmiller 
>>>>>     on Wed, 27 Oct 2021 11:43:08 -0700 writes:

    > Sounds right, though the OP appears to be assuming that the code used to generate the data objects in the file will also be there, and we need to be more definitive about that: it is not. Depending how the code was constructed, there may be useful information in the functions that were stored in the environment from which the save file was created, but this is not in any way guaranteed to be useful. In particular, there is no trace IN the RData file of which packages need to be loaded in order to access the objects stored in that RData file.
    > This is one of the reasons depending on RData files for archiving work is not advisable... and why putting code in R scripts or Sweave/knitr-based literate programming files IS recommended.

Yes, very strongly recommended.

Citation:

  The source code is real.  Objects are realizations of the source code.
  ------------------------  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

This has been the philosophy of using R-like systems
with ESS ("Emacs Speaks Statistics",  formerly 'S-mode') since the late 1980s,
also adopted by RStudio since 2011.


    > On October 27, 2021 10:47:14 AM PDT, Bert Gunter <bgunter.4567 using gmail.com> wrote:
    >> See ?load, but you may be confused. Strictly speaking, there is no code in
    >> an .Rdata file, only a (typically binary, but possibly ascii)
    >> representation of objects, usually as produced by ?save. Of course,
    >> functions are also objects, so that if you load a file with functions, the
    >> function code is available.
    >> 
    >> You can save and load command histories via ?savehistory, which, like ?save
    >> and ?load can usually be accessed through any GUI interface that you are
    >> using.
    >> 
    >> Warning: I believe the above is correct, but I may be wrong in at least
    >> some details, so give others a chance to reply and possibly correct.
    >> 
    >> Cheers,
    >> Bert
    >> 
    >> Bert Gunter
    >> 
    >> "The trouble with having an open mind is that people keep coming along and
    >> sticking things into it."
    >> -- Opus (aka Berkeley Breathed in his "Bloom County" comic strip )
    >> 
    >> 
    >> On Wed, Oct 27, 2021 at 10:18 AM Bogdan Tanasa <tanasa using gmail.com> wrote:
    >> 
    >>> Dear all, would you please advice :
    >>> 
    >>> I have an Rdata file, what is the way to print the R code that has been
    >>> used inside the Rdata file ?
    >>> 
    >>> thank you,
    >>> 
    >>> Bogdan
    >>> 
    >>> [[alternative HTML version deleted]]
    >>> 
    >>> ______________________________________________
    >>> R-help using r-project.org mailing list -- To UNSUBSCRIBE and more, see
    >>> 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.
    >>> 
    >> 
    >> [[alternative HTML version deleted]]
    >> 
    >> ______________________________________________
    >> R-help using r-project.org mailing list -- To UNSUBSCRIBE and more, see
    >> 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.

    > -- 
    > Sent from my phone. Please excuse my brevity.

    > ______________________________________________
    > R-help using r-project.org mailing list -- To UNSUBSCRIBE and more, see
    > 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.



More information about the R-help mailing list