[R] extracting a R object from an R image
Martin Maechler
m@ech|er @end|ng |rom @t@t@m@th@ethz@ch
Sat Nov 6 10:10:20 CET 2021
>>>>> Jeff Newmiller
>>>>> on Fri, 05 Nov 2021 16:45:02 -0700 writes:
> 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)
Exactly: In the eyes of most R experts, it is the only useful use of attach():
attach(".RData")
ls.str(2) # -> get alevel-1 str(.) of the objects in your image
> 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.
> ______________________________________________
> 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