I am learning python and am just getting into pandas. I am already familiar with R. I would like to be able to create a data frame in python and then somehow get it into R.
Could I do this somehow by writing the file to a CSV and then opening it into R? If so, where should I go to learn how to do this?
I found this website: http://pandas.pydata.org/pandas-docs/dev/r_interface.html that seems to be one solution - it uses rpy2 as a link between python and R. It is unclear to me, though, how the data frame actually gets opened up in R.
But I couldn't get that far because I had an error when trying to execute this code:
import pandas.rpy.common as com
I get this error:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/Library/Python/2.7/site-packages/pandas/rpy/__init__.py", line 2, in <module>
from common import importr, r, load_data
File "/Library/Python/2.7/site-packages/pandas/rpy/common.py", line 12, in <module>
from rpy2.robjects.packages import importr
File "rpy2.py", line 1, in <module>
import pandas.rpy.common as com
AttributeError: 'module' object has no attribute 'rpy'
I installed rpy2 using easy_install. It seems to be the latest version.
What should I do?