[R] extracting a R object from an R image

Jeff Newmiller jdnewm|| @end|ng |rom dcn@d@v|@@c@@u@
Sat Nov 6 00:45:02 CET 2021


IMO you are being a bit too literal. It is absolutely possible to load the file into a dedicated environment and use the $ or [[]] extraction operator to access a specific object in that environment.

?load
?new.env

Or, you can attach the file, copy to a new variable, and detach. (see examples in ?load)


On November 5, 2021 3:26:49 PM PDT, Bert Gunter <bgunter.4567 using gmail.com> wrote:
>You can't. You can only save and load whole .RData files. You can, of
>course, save and load separate R objects in separate files. But note
>in ?save.image:
>
>"For saving single R objects, saveRDS() is mostly preferable to
>save(), notably because of the functional nature of readRDS(), as
>opposed to load(). "
>
>You may wish to search on "data serialization" (e.g. on Wikipedia) or
>similar to better understand the underlying ideas.
>
>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 )
>
>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 Fri, Nov 5, 2021 at 3:01 PM Bogdan Tanasa <tanasa using gmail.com> wrote:
>>
>> Dear all,
>>
>> I saved my work in a Rimage that contains multiple objects ;
>>
>> the objects were generated with Monocle3 :
>>
>> https://cole-trapnell-lab.github.io/monocle3/docs/starting/
>>
>> one object is called CDS.
>>
>> How shall I extract this object CDS (that has a complex structure) from the
>> R image ?
>>
>> 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.
>
>______________________________________________
>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.



More information about the R-help mailing list