[Rpy] Multiple R Processes

2009-03-11 Thread Mark Larsen
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

Re: [Rpy] Multiple R Processes

2009-03-12 Thread Mark Larsen
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

[Rpy] rpy2: Conversion from RVector and RArray to Python Lists

2009-03-16 Thread Mark Larsen
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

[Rpy] rpy2 Segmentation Fault Accessing List By Index

2009-04-09 Thread Mark Larsen
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

Re: [Rpy] rpy2 Segmentation Fault Accessing List By Index

2009-04-09 Thread Mark Larsen
: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

Re: [Rpy] rpy2 Segmentation Fault Accessing List By Index

2009-04-09 Thread Mark Larsen
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

Re: [Rpy] rpy2 Segmentation Fault Accessing List By Index

2009-04-10 Thread Mark Larsen
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

Re: [Rpy] rpy2 Segmentation Fault Accessing List By Index

2009-04-12 Thread Mark Larsen
> ?! 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

Re: [Rpy] Barplot Error: rpy.RPy_RException: Error in -0.01 * height : non-numeric argument to binary operator

2009-05-15 Thread Mark Larsen
> 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 >>

Re: [Rpy] Barplot Error: rpy.RPy_RException: Error in -0.01 * height : non-numeric argument to binary operator

2009-05-22 Thread Mark Larsen
> 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

Re: [Rpy] Using R table function in rpy

2009-05-26 Thread Mark Larsen
> 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

Re: [Rpy] rpy2 ImportError: No module named win32api

2009-07-10 Thread Mark Larsen
> 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

Re: [Rpy] object not found

2009-12-08 Thread Mark Larsen
>     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"))

Re: [Rpy] What is the usage of '*' and '**' in 'r.plot(*args, **kwargs)'?

2009-12-15 Thread Mark Larsen
> 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

Re: [Rpy] rpy in Windows, how to get started?

2010-01-04 Thread Mark Larsen
> 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

Re: [Rpy] Access to R lists

2010-02-09 Thread Mark Larsen
> 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')] ---

Re: [Rpy] problem while plotting a graph

2010-03-21 Thread Mark Larsen
> 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")

Re: [Rpy] Error: is.atomic(y) is not TRUE

2010-04-26 Thread Mark Larsen
> > 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

Re: [Rpy] Fitting a glm: AttributeError: 'Robj' object has no attribute 'control'

2010-08-07 Thread Mark Larsen
> 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(