Skip to content

rpy2 / R interface (v0.16.0) #10062

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
borisRa opened this issue May 5, 2015 · 8 comments
Closed

rpy2 / R interface (v0.16.0) #10062

borisRa opened this issue May 5, 2015 · 8 comments
Labels
Deprecate Functionality to remove in pandas Docs

Comments

@borisRa
Copy link

borisRa commented May 5, 2015

Hi,

Using the last pandas version, the command : "import pandas.rpy.common as com"

produces the following warning :
"The pandas.rpy module is deprecated and will be removed in a future version. We refer to external packages like rpy2, found here: http://rpy.sourceforge.net "like rpy2, found here: ttp://rpy.sourceforge.net", FutureWarning) "

I use the following functionality heavily :
com.convert_to_r_dataframe(pandas_DF)
com.convert_robj(results_from_R)

How with rpy2 I can do the same ?

Regards,
Boris

@jorisvandenbossche
Copy link
Member

See #9602.
We were actually a little bit too fast with the deprecation, before we could put good docs in place on how to port to rpy2 (and the docs in rpy2 itself on this are also not very clear)

I think you can start with this: http://stackoverflow.com/questions/20630121/pandas-how-to-convert-r-dataframe-back-to-pandas
And we would really appreciate some feedback/problems you encounter (eg things that work in pandas but not with rpy2), you can report that at #9602

@jreback jreback added Docs Deprecate Functionality to remove in pandas labels May 5, 2015
@jreback
Copy link
Contributor

jreback commented May 5, 2015

closing in favor of #9602

@jreback jreback closed this as completed May 5, 2015
@jorisvandenbossche
Copy link
Member

@borisRa Here is a notebook exploring some things: http://nbviewer.ipython.org/gist/jorisvandenbossche/d0deaa53ace697e1514e

Basically:

  • imports:

    import rpy2.robjects.conversion as conversion
    from rpy2.robjects import pandas2ri
    pandas2ri.activate()
    
  • after that, you can change:

  • com.convert_to_r_dataframe(df) -> conversion.py2ri(df)

  • com.convert_robj(rdf) -> conversion.ri2py(rdf)

Does this work for you?

@borisRa
Copy link
Author

borisRa commented May 6, 2015

Thanks ! that is exactly what I looked for !

@borisRa
Copy link
Author

borisRa commented May 6, 2015

And what are the alternatives for :

import pandas.rpy.common as com
pydf = com.load_data('iris')
r_matrix = com.convert_to_r_matrix(df)

Thanks,
Boris

@jorisvandenbossche
Copy link
Member

For the data, does this work?

from rpy2.robjects import r
r.data(name)
robj = r[name]
conversion.ri2py(robj)

@jorisvandenbossche
Copy link
Member

And for the matrix, this is actually just using convert_to_r_dataframe, and then using the R as.matrix function.

@borisRa
Copy link
Author

borisRa commented May 6, 2015

Everything works as a charm !
Thanks !

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Deprecate Functionality to remove in pandas Docs
Projects
None yet
Development

No branches or pull requests

3 participants