Questions tagged [rpy2]

RPy is a very simple, yet robust, Python interface to the R Programming Language. It can manage all kinds of R objects and can execute arbitrary R functions (including the graphic functions). All errors from the R language are converted to Python exceptions. Any module installed for the R system can be used from within Python

RPy is a very simple, yet robust, Python interface to the R Programming Language. It can manage all kinds of R objects and can execute arbitrary R functions (including the graphic functions). All errors from the R language are converted to Python exceptions. Any module installed for the R system can be used from within Python.

rpy2 is a redesign and rewrite of rpy. It is providing a low-level interface to R, a proposed high-level interface, including wrappers to graphical libraries, as well as R-like structures and functions.

https://rpy2.bitbucket.io

1203 questions
5
votes
2 answers

memory leak with rpy

I have a small part in my code thats similar to this one (ofcourse with real matrices instead of the zero filled ones): x = [rinterface.FloatSexpVector([0]*(1000**2)) for i in xrange(20)] y = robjects.r('list')(x) and it looks like its causing…
itai
  • 1,566
  • 1
  • 12
  • 25
4
votes
1 answer

Import rpy2 : unable to determine R library path

I would like to import rpy2 to load R package from rpy2.robjects.packages import importr I have an error: Unable to determine R library path: Command '(...Miniconda3\\lib\\R\\bin\\Rscript', '-e', 'cat(Sys.getenv("LD_LIBRARY_PATH"))')' returned…
NCall
  • 113
  • 6
4
votes
2 answers

Guidance in using rpy2 eval expression

I am new to both R and rpy2. I am trying to port the following example library(MASS) # for eqscplot data(topo, package="MASS") topo.kr <- surf.ls(2, topo) trsurf <- trmat(topo.kr, 0, 6.5, 0, 6.5, 50) to rpy2. So far I have import …
Kabira K
  • 1,916
  • 2
  • 22
  • 38
4
votes
0 answers

Unable to install rpy2 on MAC OS due to ERROR: Failed building wheel for backports.zoneinfo

I am trying to install rpy2 on my mac. I have tried to use the command pip install rpy2 but I get the following error: ?25h ERROR: Failed building wheel for backports.zoneinfo Failed to build backports.zoneinfo ERROR: Could not build wheels for…
rvenky97
  • 49
  • 1
  • 2
4
votes
1 answer

Using rpy2: cannot find R package that is installed

I am trying to use R in combination with Python with rpy2. More specifically, I am trying to use some code written by someone else that uses rpy2. I think the code that uses rpy2 is: import rpy2.robjects as robjects integrated_result =…
Max
  • 405
  • 2
  • 11
4
votes
1 answer

rpy2 convert Matrix -> DataFrame

I am having difficulty with this seemingly simple operation that I'd assume has been solved previously but I cannot find any examples. In the R environment @data is of type DataFrame but rpy2 (2.2) is returning a Matrix. Is there a convirent way to…
Stephen
  • 125
  • 1
  • 6
4
votes
2 answers

Rpy2 in a Flask App: Fatal error: unable to initialize the JIT

I have a Flask app, and I'm trying to add a RESTful endpoint that uses rpy2 to load a model from a .rds file. When I run my test script with python3 testscript.py that contains import rpy2.robjects as objects, it works fine. However when I try the…
zgnohc
  • 41
  • 1
  • 4
4
votes
1 answer

How to set a custom R installation for using rpy2 in Jupyter?

I have a conda environment which I made available as a kernel to my Jupyter instance by running: python -m ipykernel install --user --name my-env-name --display-name "Python (my-env-name)" With this environment I wanted to use R in Jupyter taking…
Martin Becker
  • 3,331
  • 3
  • 22
  • 25
4
votes
5 answers

R kernel crashes while loading R package using rpy2

First of all, I’m new to rpy2 / jupyter so please don’t judge me if this isn’t the correct place to ask my question. I am trying to set up an integrated workflow for data analysis using R and Python and I encounter the following error: I am on…
fkoegel
  • 43
  • 4
4
votes
2 answers

Is multiprocessing with RPy safe?

Is it safe to call RPy functions in a multiprocessing environment and are there any multiprocessing issues regarding RPy that one should be aware of? A simple example might be the following: from multiprocessing import Pool from rpy import * def…
Nixuz
  • 3,439
  • 4
  • 39
  • 44
4
votes
1 answer

Rpy2 - calling functions with a dot in their name

I am trying to call the R function memory.limit, with the argument 'size', using rpy2. I followed the instructions given here: Accessing functions with a dot in their name (eg. "as.vector") using rpy2, but cannot get it to work. This is what I have…
panda
  • 821
  • 1
  • 9
  • 20
4
votes
4 answers

Converting .sav file to pandas dataframe

I'm in the process of writing a data checker to review spss files and need to programmatically handle different checks. The first step is to access an spss file, convert it to a pandas dataframe and run my checks from there. The only way I've found…
grigs
  • 1,140
  • 3
  • 15
  • 28
4
votes
0 answers

How to instal rpy2 on mac OS - Library not loaded:

This is proving to be very difficult on mac os and python3. Below is are the paths for R. I have them and pointed to them. So why the problem? From the command line: 1) which R /usr/local/bin/R 2) R…
Tampa
  • 75,446
  • 119
  • 278
  • 425
4
votes
1 answer

Use rpy2 with pandas dataframe

I want to aplly some R function to a pandas dataframe df = pd.DataFrame( np.random.randn(5,2), # 5 rows, 2 columns columns = ["A","B"], # name of columns index = ["Max", "Nathy", "Tom", "Joe", "Kathy"] ) How can I…
Joe
  • 561
  • 1
  • 9
  • 26
4
votes
1 answer

Running R script in Python

I am running a simple R script in python using the following code. import rpy2.robjects as robjects r=robjects.r output = r.source("sample.R") Now when I print the output print (output) I am getting script's last variable only as an output and…
Jaws
  • 65
  • 2
  • 8