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
108
votes
7 answers

How to create an empty R vector to add new items

I want to use R in Python, as provided by the module Rpy2. I notice that R has very convenient [] operations by which you can extract the specific columns or lines. How could I achieve such a function by Python scripts? My idea is to create an R…
ligwin
  • 1,151
  • 3
  • 10
  • 7
77
votes
4 answers

Controlling the order of points in ggplot2?

I'm plotting a dense scatter plot in ggplot2 where each point might be labeled by a different color: df <- data.frame(x=rnorm(500)) df$y = rnorm(500)*0.1 + df$x df$label <- c("a") df$label[50] <- "point" df$size <- 2 ggplot(df) +…
user248237
65
votes
4 answers

How do Rpy2, pyrserve and PypeR compare?

I would like to access R from within a Python program. I am aware of Rpy2, pyrserve and PypeR. What are the advantages or disadvantages of these three options?
DanB
  • 3,755
  • 4
  • 22
  • 22
54
votes
3 answers

Python interface for R Programming Language

I am quite new to R, and pretty much used to python. I am not so comfortable writing R code. I am looking for python interface to R, which lets me use R packages in pythonic way. I have done google research and found few packages which can do…
darshan
  • 1,230
  • 1
  • 11
  • 17
33
votes
3 answers

Converting python objects for rpy2

The following code is supposed to create a heatmap in rpy2 import numpy as np from rpy2.robjects import r data = np.random.random((10,10)) r.heatmap(data) However, it results in the following error Traceback (most recent call last): File…
Boris Gorelik
  • 29,945
  • 39
  • 128
  • 170
31
votes
1 answer

Calling R script from python using rpy2

I'm very new to rpy2, as well as R. I basically have a R script, script.R, which contains functions, such as rfunc(folder). It is located in the same directory as my python script. I want to call it from Python, and then launch one of its functions.…
Efferalgan
  • 1,681
  • 1
  • 14
  • 24
28
votes
9 answers

rpy2 install on windows 7

I'm trying to install rpy2 on my computer, but I wasn't able to do it. I downloaded the source package and I tryed to install Rpy2 (rpy2-2.3.2) using the command python setup.py install. This is the result: running install running build running…
Luca Chiappi
  • 289
  • 1
  • 3
  • 5
27
votes
0 answers

Differential gene expression analysis in Python

It seems that most differential gene expression packages for RNA-Seq are written in R. Examples include: - edgeR - limma - DESeq Are any similar (and easy to use) packages available for Python, or have any of the R packages been ported? The best I…
ljc
  • 943
  • 2
  • 10
  • 26
26
votes
7 answers

Converting an RPy2 ListVector to a Python dictionary

The natural Python equivalent to a named list in R is a dict, but RPy2 gives you a ListVector object. import rpy2.robjects as robjects a = robjects.r('list(foo="barbat", fizz=123)') At this point, a is a ListVector object.
cbare
  • 12,060
  • 8
  • 56
  • 63
22
votes
7 answers

How to implement R's p.adjust in Python

I have a list of p-values and I would like to calculate the adjust p-values for multiple comparisons for the FDR. In R, I can use: pval <- read.csv("my_file.txt",header=F,sep="\t") pval <- pval[,1] FDR <- p.adjust(pval, method=…
drbunsen
  • 10,139
  • 21
  • 66
  • 94
22
votes
3 answers

Plotting 3-tuple data points in a surface / contour plot using matplotlib

I have some surface data that is generated by an external program as XYZ values. I want to create the following graphs, using matplotlib: Surface plot Contour plot Contour plot overlayed with a surface plot I have looked at several examples for…
morpheous
  • 16,270
  • 32
  • 89
  • 120
22
votes
2 answers

Difference in Python statsmodels OLS and R's lm

I'm not sure why I'm getting slightly different results for a simple OLS, depending on whether I go through panda's experimental rpy interface to do the regression in R or whether I use statsmodels in Python. import pandas from rpy2.robjects import…
Skylar Saveland
  • 11,116
  • 9
  • 75
  • 91
21
votes
3 answers

Minimal example of rpy2 regression using pandas data frame

What is the recommended way (if any) for doing linear regression using a pandas dataframe? I can do it, but my method seems very elaborate. Am I making things unnecessarily complicated? The R code, for comparison: x <- c(1,2,3,4,5) y <-…
mjandrews
  • 2,392
  • 4
  • 22
  • 39
21
votes
3 answers

Python Pandas to R dataframe

I am going to convert Python pandas dataframe to dataframe in R. I found out few libraries for this problem http://pandas.pydata.org/pandas-docs/stable/r_interface.html which is rpy2 But I couldn't find the methods for saving or transfer it to…
JonghoKim
  • 1,965
  • 7
  • 21
  • 44
18
votes
3 answers

Module 'rpy2.robjects.pandas2ri' has no attribute 'ri2py'

I'm trying to convert R-dataframe to Python Pandas DataFrame. I use the following code: from rpy2.robjects import pandas2ri pandas2ri.activate() r_dataframe = r_function(my_dataframe['Numbers']) print(r_dataframe) python_dataframe =…
Denis
  • 357
  • 1
  • 3
  • 10
1
2 3
80 81