The API changed between the moment this was first written and the 
release 2.0.0.

You want:
letters.r_repr()

(the fix to the doc is in SVN for one or two days).


L.




Marcos Silva wrote:
> Hi People,
> 
> What is wrong with these two piece of code?
> 
> The following is an example presented in RPy2 manual
> 
>  >>> import rpy2.robjects as robjects
>  >>> letters = robjects.r['letters']
>  >>> letters
> <RVector - Python:0x013253F0 / R:0x02435198>
>  >>> print letters
>  [1] "a" "b" "c" "d" "e" "f" "g" "h" "i" "j" "k" "l" "m" "n" "o" "p" "q" 
> "r" "s"
> [20] "t" "u" "v" "w" "x" "y" "z"
>  >>> rcode = 'paste(%s, collapse="-")' %(repr(letters))
>  >>> robjects.r(rcode)
> Traceback (most recent call last):
>   File "<interactive input>", line 1, in <module>
>   File "C:\Program 
> Files\Python25\Lib\site-packages\rpy2\robjects\__init__.py", line 522, 
> in __call__
>     p = self.parse(text=string)
>   File "C:\Program 
> Files\Python25\Lib\site-packages\rpy2\robjects\__init__.py", line 413, 
> in __call__
>     res = super(RFunction, self).__call__(*new_args, **new_kwargs)
> RRuntimeError: Erro em function (file = "", n = NULL, text = NULL, 
> prompt = "?", srcfile = NULL,  :
>   unexpected '<' in "paste(<"
> 
>  >>
> 
> And this is a trying of using the stem() R function:
> 
>  >>> import rpy2.robjects as ro
>  >>> x = ro.FloatVector([32, 45, 28, 76, 29, 46, 18, 75, 86, 95, 74, 46, 
> 39, 76, 126])
>  >>> x
> <FloatVector - Python:0x013173F0 / R:0x02435100>
>  >>> print x
>  [1]  32  45  28  76  29  46  18  75  86  95  74  46  39  76 126
>  >>> stem = ro.r['stem']
>  >>> stem(x)
> <RObject - Python:0x013174E0 / R:0x011724A0>
>  >>> print stem(x)
> NULL
>  >>>
> 
> Any idea of what is wrong?
> 
> 
> 
> 
> 
>  
> 
> -- 
> Marcos F. Silva
> http://marcosfs2006.googlepages.com
> 
> 
> ------------------------------------------------------------------------
> 
> ------------------------------------------------------------------------------
> SF.Net email is Sponsored by MIX09, March 18-20, 2009 in Las Vegas, Nevada.
> The future of the web can't happen without you.  Join us at MIX09 to help
> pave the way to the Next Web now. Learn more and register at
> http://ad.doubleclick.net/clk;208669438;13503038;i?http://2009.visitmix.com/
> 
> 
> ------------------------------------------------------------------------
> 
> _______________________________________________
> rpy-list mailing list
> rpy-list@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/rpy-list


------------------------------------------------------------------------------
SF.Net email is Sponsored by MIX09, March 18-20, 2009 in Las Vegas, Nevada.
The future of the web can't happen without you.  Join us at MIX09 to help
pave the way to the Next Web now. Learn more and register at
http://ad.doubleclick.net/clk;208669438;13503038;i?http://2009.visitmix.com/
_______________________________________________
rpy-list mailing list
rpy-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/rpy-list

Reply via email to