I'm just starting to learn how to use rpy2 with python. I'm able to make simple plots and such, but I've run into the problem that many options in R use ".". For example, here's an R call that works:
barplot(t, col=heat.colors(2), names.arg=c("pwn", "pwn2"))
where t is a matrix.
I want to use the same call in python, but it reje...
The following code is supposed to created 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 "z.py", line 8, in <module>
labRow=rowNames, labCol=colNames)
File "C:\Python25\lib\...
I have a data.frame in R. It contains a lot of data : gene expression levels from many (125) arrays. I'd like the data in Python, due mostly to my incompetence in R and the fact that this was supposed to be a 30 minute job.
I would like the following code to work. To understand this code, know that the variable path contains the full pa...
Hello!
The following code does not work. It seems that the R warning message raises a python error.
# enable use of python objects in rpy2
import rpy2.robjects.numpy2ri
import numpy as np
from rpy2.robjects import r
# create an example array
a = np.array([[5,2,5],[3,7,8]])
# this line leads to a warning message, which in turn raises ...
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 plotting surfaces and contours in matplotlib - however, the Z values seems to be a functio...
I'm using rpy2 to do data analysis and plotting in python. It works fine except for the fact that when I draw a plot, it's window hangs around until the program terminates. Is there a way to clear the plot during runtime? Additionally, If I ever resize the window, the plot disappears, but the window remains. When using R interactively, r...
I am writing a data processing program in Python and R, bridged with Rpy2.
Input data being binary, I use Python to read data out and pass them to R, then collect results to output.
Data are organized into pieces, each being around 100 Bytes (1Byte per value * 100 values).
They just work now, but the speed is very low. Here are some o...
I have a feeling this will be a quick fix, given that I started coding two weeks ago. I am try to run a statistical test - a Mantel, looking for a correlation between two distance matrices - in Python, by using a function(?) that has already been written in R, via Rpy2. The R module is "ade4" and it contains "mantel.rtest"
from rpy2 im...
Hello guys,
I'm having some trouble to understand the mapping with rpy2 object and python object.
I have a function(x) which return a tuple object in python, and i want to map this tuple object with R object list or vector.
First, i'm trying to do this :
# return a python tuple into this r object tlist
robjects.r.tlist = get_max_ticks...
Hi all,
I'm tying to execute an R script from python, ideally displaying and saving the results. Using rpy2 has been a bit of a struggle, so I thought I'd just call R directly. I have a feeling that I'll need to use something like "os.system" or "subprocess.call," but I am having difficulty deciphering the module guides.
Here's the R...
Hi, 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 a R vector and add those wanted elements into this vecotr so that the final vector is the same...
Hi, I got the following R code and I need to convert it to python and run it in python environment, basically I have done this with rpy2 module, but it looks kind of dull with python doing the same things, so could someone find a better way to rewrite the following R code to an equivalent python script with the rpy2 module?
mymad <- fun...
i am using rpy2-2.0.7 (i need this to work with windows 7, and compiling the binaries for the newer rpy2 versions is a mess) to push a two-column dataframe into r, create a few layers in ggplot2, and output the image into a <.png>.
i have wasted countless hours fidgeting around with the syntax; i did manage to output the files i neede...
I have the following two lines of code that both run fine in both R and Python (via Rpy):
[R] rcut = cut(vector, brks)
[Python] rcut = r.cut(vector, brks)
However, if I want to add the argument of include.lowest=TRUE, it runs as expected in R:
[R] rcut = cut(vector, brks, include.lowest=TRUE)
But it doesn't work in Rpy:
[Python] r...
The real goal here is to find the quantile means (or sums, or median, etc.) in Python. Since I'm not a power user of Python but have used R for a while, my chosen route is via Rpy. However, I ran into the problem that the returned list of means are not correspondent to the order of the quantiles. In particular, I have the followings in R...
Hi everyone,
I am trying, so far unsuccessfully, at installing the rpy2 for python on my Mac OSX. I have tried Macports and DarwinPorts but have had no luck with import rpy2 within the python shell environment. I don't know much about programming in Mac and I am a wiz at installing modules on a Windoze based system, but for the life of...
Hello Guys,
With psycopg2, i get result of query in this form :
[(15002325, 24, 20, 1393, -67333094L,
38, 4, 493.48763257822799,
493.63348372593703), (15002339, 76, 20, 1393, -67333094L, 91, 3,
499.95845909922201, 499.970048093743), (15002431, 24, 20, 1394, -67333094L,
38, 4, 493.493464900383,
493.63348372593703), (150024...
Hello,
I've searched far and wide, read a previous question in stackoverflow but cant seem to solve the problem of installing rpy2 on my Mac with OS X 10.5.8.
I have Xcode 3.1.4 installed and R 2.1.11.
when I run:
sudo python setup.py build install
I get this:
running build
running build_py
running build_ext
building 'rpy2.rinterfac...