FWIW, the solution I have for now is to use dump(ls(), file="") to get a
deparsed string representation of all the objects in memory, which can
then be pickled. I'm not having problems with it right now in any simple
cases, but I can imagine there are situations where deparsing gets
hairy, so being able to pickle the R globalEnv or somehow being able to
route the file output of R's save.image command to a python object that
can then be pickled would be the best....

Cheers,
-brandon invergo

On Thu, 2009-04-30 at 01:01 +0200, Brandon Invergo wrote:
> I'm trying to do something similar: I'd like to create a save file that
> includes the current state of the R environment. I don't want to create
> a separate file for the R environment via one of R's built-in commands,
> so I thought I'd pickle globalEnv alongside some other objects I'm
> pickling. When I try to pickle the globalEnv, I get this error:
> cPickle.PicklingError: Can't pickle <type 'rinterface.SexpEnvironment'>:
> import of module rinterface failed
> 
> 
> How have other people gone about storing their R objects?
> 
> Thanks!
> brandon invergo
> 
> 
> 
> On Mon, 2009-04-06 at 11:29 -0400, Réjean Ducharme wrote:
> > Hi all,
> 
> I'm using Rpy2 to train a logistic regressor (using the "glm" function 
> in R), and I need to save the model for futher use.
> I naively try to use pickle, but I have an error message:
> 
> import rpy2.robjects as robjects
> fit = robjects.r.glm(formula=f, family=robjects.r.binomial(), data=data)
> output = open('glm.pickle', 'w')
> pickle.dump(fit, output)
> 
>  >>>  pickle.PicklingError: Can't pickle <type
> 'rinterface.SexpVector'>: 
> it's not found as rinterface.SexpVector
> 
> 
> Is there another way to save a Rpy2 object???
> 
> Thanks,
> Rejean Ducharme
> 
> 
> ------------------------------------------------------------------------------
> Register Now & Save for Velocity, the Web Performance & Operations 
> Conference from O'Reilly Media. Velocity features a full day of 
> expert-led, hands-on workshops and two days of sessions from industry 
> leaders in dedicated Performance & Operations tracks. Use code vel09scf 
> and Save an extra 15% before 5/3. http://p.sf.net/sfu/velocityconf
> _______________________________________________
> rpy-list mailing list
> rpy-list@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/rpy-list


------------------------------------------------------------------------------
Register Now & Save for Velocity, the Web Performance & Operations 
Conference from O'Reilly Media. Velocity features a full day of 
expert-led, hands-on workshops and two days of sessions from industry 
leaders in dedicated Performance & Operations tracks. Use code vel09scf 
and Save an extra 15% before 5/3. http://p.sf.net/sfu/velocityconf
_______________________________________________
rpy-list mailing list
rpy-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/rpy-list

Reply via email to