Here you are:
>>> from rpy import *
>>> a=[1,2,3,4]
>>> b=r['<'](a,3)
>>> b
[True, True, False, False]
>>>
2008/7/25 Zhang, Minhua <[EMAIL PROTECTED]>:
> In R, I could do:
>
> > a <- c(1,2,3,4)
> > smalla <- a<3
> > smalla
> [1] TRUE TRUE FALSE FALSE
>
> But how do I create such a variable 'smalla' in python via RPy?
>
> Here is what I tried, none works:
> >>> from rpy import *
> >>> a = (1,2,3,4)
> >>> smalla = r(a<3)
> >>> smalla
> False
> >>> smalla = r("a<3")
> Traceback (most recent call last):
> File "<interactive input>", line 1, in <module>
> File "C:\Python25\Lib\site-packages\rpy.py", line 322, in __call__
> return self.eval(self.parse(text=s))
> RPy_RException: Error in eval(expr, envir, enclos) : object "a" not found
> >>> smalla = r("x<3", r.data_frame(x=a))
> Traceback (most recent call last):
> File "<interactive input>", line 1, in <module>
> TypeError: __call__() takes exactly 2 arguments (3 given)
> >>>
>
> Many thanks,
> Minhua
>
> DISCLAIMER: This e-mail message and any attachments are intended solely for
> the use of the individual or entity to which it is addressed and may contain
> information that is confidential or legally privileged. If you are not the
> intended recipient, you are hereby notified that any dissemination,
> distribution, copying or other use of this message or its attachments is
> strictly prohibited. If you have received this message in error, please
> notify the sender immediately and permanently delete this message and any
> attachments.
>
> -------------------------------------------------------------------------
> This SF.Net email is sponsored by the Moblin Your Move Developer's
> challenge
> Build the coolest Linux based applications with Moblin SDK & win great
> prizes
> Grand prize is a trip for two to an Open Source event anywhere in the world
> http://moblin-contest.org/redirect.php?banner_id=100&url=/
> _______________________________________________
> rpy-list mailing list
> rpy-list@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/rpy-list
>
>
-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
_______________________________________________
rpy-list mailing list
rpy-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/rpy-list