Felipe Ortega wrote:
> Then I need to do the equivalen to this in R syntax:
> 
>  > barlow = bar[bar<somevalue]
> 
> i.e, I want to use a logical vector.
> 
> With RPY in Python this doesn't work:
> 
> r.assign("barlow", r.bar[r.bar<somevalue])
> 
> It seems that the Python interpreter evaluates de logical expression and 
> so I don't get the expected behaviour.

Yes, python will evaluate "r.bar < somevalue" and depending on the 
nature of the objects you will probably get a single boolean 
(true/false) on an error.

(Python does this as a scalar operation, R as a vector operation - 
acting on each element of the list)

> Does anyone have some hint about this?

Try getting R to do the logical evaluation like this?

r("barlow <- bar[bar < somevalue]")

assuming you have setup the variables bar and somevalue in R already 
(and not just in python).

Or, you could try  something like this in python using list comprehensions:

[x < somevalue for x in bar]

e.g.

mylist = [1,2,3,4,5,6,7,8]
mybooleanlist = [x < 6 for x in mylist]

That should give you a list of booleans:

[True, True, True, True, True, False, False, False]

Peter

-------------------------------------------------------------------------
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
_______________________________________________
rpy-list mailing list
rpy-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/rpy-list

Reply via email to