[R] Saving environment object

Henrik Bengtsson hb at stat.berkeley.edu
Fri Aug 15 16:53:57 CEST 2008


Hi,

can you please give a reproducible example and what's your sessionInfo()?

Many years ago when I started to develop the Object class in R.oo,
which is using environments, I also had problems saving environments
directly.  I my case I think it was when I added a class attribute to
an environment, but I don't remember the details [theys are somewhere
in the R-devel archives].  I never understood why it didn't work.
What solved my problem was to put the environment as a element of
something before save, e.g. in a list or as an attribute.  So try
this:

env <- new.env();
...
x <- list(env=env);
save("x", file="x.RData");

It might help

/Henrik

On Fri, Aug 15, 2008 at 4:41 AM, Benjamin Otto
<b.otto at uke.uni-hamburg.de> wrote:
> Hi,
>
> When I create an environment object with new.env() and populate it with
> values then how can I save it into an .RData file properly, so it can be
> loaded later on in a new session?
>
> Saving an environment object with save() or save.image() results in an error
> message when loading again:
>
> Error: protect(): protection stack overflow
>
> Regards,
>
> benjamin
>
> ======================================
> Benjamin Otto
> University Hospital Hamburg-Eppendorf
> Institute For Clinical Chemistry
> Martinistr. 52
> D-20246 Hamburg
>
> Tel.: +49 40 42803 1908
> Fax.: +49 40 42803 4971
> ======================================
>
>
>
> --
> Pflichtangaben gemäß Gesetz über elektronische Handelsregister und Genossenschaftsregister sowie das Unternehmensregister (EHUG):
>
> Universitätsklinikum Hamburg-Eppendorf
> Körperschaft des öffentlichen Rechts
> Gerichtsstand: Hamburg
>
> Vorstandsmitglieder:
> Prof. Dr. Jörg F. Debatin (Vorsitzender)
> Dr. Alexander Kirstein
> Ricarda Klein
> Prof. Dr. Dr. Uwe Koch-Gromus
>
>
> ______________________________________________
> R-help at r-project.org mailing list
> 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