1

I have a python S4 object that i want to store for future use in python using rpy2. I then wish to import this from a file back into R when required. How would I go about doing this?

Python 2.7 R 3.1.2

asdfwi
  • 21
  • 4
  • Please review [How do I ask a good question?](http://stackoverflow.com/help/how-to-ask) and improve your question. – Ram Feb 12 '15 at 02:42
  • Specifically add some code to make a [reproducible example](http://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example) – MrFlick Feb 12 '15 at 04:11
  • If S4 is referred to the objects in R, your best bet would be to save objects in .RData files (`save(..., file = ".RData")`.). – Roman Luštrik Feb 12 '15 at 12:05

1 Answers1

0

In python you can start with observing the slot names of your R object as follows:

import rpy2.robjects as robjects
from rpy2.robjects.packages import importr, data
import rpy2.robjects.numpy2ri as rpynp

tuple(object.slotnames())

This gives the parameter names of your object. You could then see the parameter values:

x = object.slots['slotname']

I assume you can figure out how to save your data into a file and how to import it in R.

I hope this answers your question. I agree with @Ram that your question is not so clear. Good luck.

phageman
  • 63
  • 1
  • 6