> model = rpy.r.glm(formula, data = d, family = 'binomial', control =
> rpy.r.glm.control(maxit = 500))
>
> Traceback (most recent call last):
> File "", line 1, in
> AttributeError: 'Robj' object has no attribute 'control'
It doesn't like the dot in the function name. Use:
model = rpy.r.glm(
>
> Apolagize if this is a stupid question. When I run the following script
>
> import rpy2.robjects as robjects
> x=[5.05,6.75,3.21,2.65]
> y=[1.65,2.64,2.64,6.95]
> print robjects.r.cor(x,y,method="spearman")
>
>
rpy2 is a lot more careful with automatic conversions. Try:
robjects.r.cor(rob
> Hi, my problem is that when I use plot command, I can see for few second
> the graph but the window is closed quickly.
The python script is exiting and taking the R plot window with it.
Add, something like this to the end of your script:
raw_input("Press any Key To Exit")
> If the above does not work, how do I access items in the returned list?
I frequently work like this:
an_r_list=robjects.r('list(one=1,two=2)')
list_names = [name for name in robjects.r.names(an_r_list)]
value, = an_r_list[list_names.index('one')]
---
> What is wrong?
Eva,
Make sure you are reading these docs for rpy2 here:
http://rpy.sourceforge.net/rpy2/doc/html/introduction.html#getting-started
And not the ones for rpy, they are very different implementations.
(IMHO, I'd stick with rpy2 over rpy).
You want this:
from rpy2 import robject
> I don't understand what '*' and '**' mean. Could somebody let me know?
This is a python thing. '*' means that any number of arguments can be
passed as a tuple.
For instance, I have function:
def add(a,b):
return a+b
I could call this with a tuple argument:
var = (4,5)
add(*var)
'**' mean
> slope1 = with_mode(NO_CONVERSION, r.zyp.sen)(r("p~t"))
A quick glance tells me this line is a problem. The "." is reserved
in Python for modules/classes, try with an underscore:
slope1 = with_mode(NO_CONVERSION, r.zyp_sen)(r("p~t"))
> ImportError: No module named win32api
>
> What am I to do?
Install the win32 extensions:
http://python.net/crew/mhammond/win32/
--
Enter the BlackBerry Developer Challenge
This is your chance to win up to $100,000 in
> table = r.table(wordsvector)
The table function returns a _contingency table_ object, which rpy
tries to unsuccessfully convert into a numpy array.
See if this returns something more workable:
rObj = with_mode(NO_CONVERSION, r.table)(words)
aHash = {}
[aHash.update(i) for i in rObj]
print aHas
> How do I get the matrix() function (or array for that matter) working
> properly for me!
Hmm, this works perfectly for me:
>>> import numpy
>>> from rpy import r
>>> import numpy
>>> bars = numpy.array([[25,15,26,25,18],[45,32,28,12,45]])
>>> r.barplot(bars)
[0.69996, 1.899
> Traceback (most recent call last):
> File "r_test.py", line 70, in ?
> r.barplot(bars, beside = "TRUE" )
> rpy.RPy_RException: Error in -0.01 * height : non-numeric argument to binary
> operator
Your Numeric array is being converted into a list.
>>> from rpy import r
>>> import Numeric
>>
> ?! Weren't you on a Linux machine ?
> (aqua is for OS X, and your machine is amd64 - not something OS X is
> known to be officially working on)
Yes, Gentoo linux.
> Did you try having the install clearly distinct by using the option
> --prefix (and a setting PYTHONPATH accordingly) ?
I ended u
Thanks Laurent.
> Where was the hack needed ?
> Setting your target R as the first one found in the PATH should be
> enough.
You are correct, I didn't need to hack it, I wasn't sure. My hack was
to hardcode RHOMES.
A little progress. rpy2.robjects imports against R version 2.8.1 but
when I do
Hate to keep replying to my own message but...
I thought I'd throw a newer version of R at this problem. My above errors
are with 2.7.1 and I thought I'd test with 2.8.2 (my development box, where
all works well is at 2.7.2). I kept my main 2.7.1 install in /usr/lib64 and
installed 2.8.2 into /u
:59 PM, Mark Larsen wrote:
> I have an R function that returns a list of Matrices and Vectors.
>
> I've been processing the return list like:
>
> rpyRV = rpy2.robjects.r.someFunc()
> for property,rObj in zip([i for i in rpyRV.getnames()],[i for i in rpyRV]):
> # do
I have an R function that returns a list of Matrices and Vectors.
I've been processing the return list like:
rpyRV = rpy2.robjects.r.someFunc()
for property,rObj in zip([i for i in rpyRV.getnames()],[i for i in rpyRV]):
# do stuff with results
On my development box (64 bit, dual XEON) everythi
I'm taking the plunge and switching over to rpy2. While, Python to RObjects
seems straightforward, what about the reverse?
For example, I have a R function which returns a matrix. How can I get this
into a list of lists OR loop over each column (or row) pulling the vector
one at a time? What's
Thanks Nathaniel!
> Spawn multiple Python processes, each of which uses rpy2 to load
R, and talk to them over any Python-level IPC library.
The latter is really a huge improvement over the former, because there
are great IPC libraries for python -- e.g., the pyprocessing library
(included by defau
I realize this has been hammered to death, but I can't seem to get my head
around it.
Is the mapping from rpy (or rpy2) to R a one-to-one? Can either invoke
multiple R processes from a single python program?
In the past I've used python threads and piped stdin/stdout to multiple R
processes to t
19 matches
Mail list logo