Skip to content

Instantly share code, notes, and snippets.

@lgautier
Created March 25, 2023 16:24
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save lgautier/79489dcf8b56dd71149b28e9b375ca0e to your computer and use it in GitHub Desktop.
Save lgautier/79489dcf8b56dd71149b28e9b375ca0e to your computer and use it in GitHub Desktop.
Python 3.8.10 (default, Mar 13 2023, 10:26:41)
Type 'copyright', 'credits' or 'license' for more information
IPython 8.11.0 -- An enhanced Interactive Python. Type '?' for help.
In [1]: from rpy2.robjects.packages import importr
In [2]: reticulate = importr('reticulate')
WARNING: The R package "reticulate" only fixed recently
an issue that caused a segfault when used with rpy2:
https://github.com/rstudio/reticulate/pull/1188
Make sure that you use a version of that package that includes
the fix.
In [3]: pytime = getattr(reticulate, 'import')('time')
In [4]: import rpy2.robjects as ro
In [5]: ro.r('`$`')(pytime, 'ctime')()
Out[5]:
<rpy2.robjects.vectors.StrVector object at 0x7f5401897140> [RTYPES.STRSXP]
R classes: ('character',)
['Sat Mar 25 12:21:32 2023']
In [6]:
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment