Hi Laurent,

Once again, thanks very much.

I'm not a Python user. I'm trying learn a little about it, so it was useful
your hint about the 'pydoc string'.

I will try the approach you suggested using R's sink() function or maybe the
capture.output() function.

As the R's stem() function works on RPy1x  I  thought that it could work in
rpy2 too.

Cheers.







2008/12/16 Laurent Gautier <lgaut...@gmail.com>

> Cc'ing the answer to the list (as it may interest others).
>
>
> Marcos Silva wrote:
>
>> Hi Laurent,
>>
>> Thanks for your quick response.
>>
>> By the way, can I use **r_repr()**  [well, by now I don't know for what is
>> this function for :) ] to solve the problem with the R stem() function that
>> I mentioned in my previous email?
>>
>
> what about using the pydoc string ?
>
> import rpy2.robjects as ro
> help(ro.RObject.r_repr)
>
>
> The R "stem" function only has side-effects: it does not return a string,
> and does not provide an option to return a string.
> Whether this is to be considered unfortunate or not should be discussed on
> the r-devel mailing list.
>
> On win32, the console I/O functions are currently not working (so "stem"
> will not produce anything on that platform).
> http://rpy.sourceforge.net/rpy2/doc/html/overview.html#test-an-installation
>
> You may consider using R's sink function in order to circumvent both the
>  fact that "stem" is not returning anything and that I/O is problematic
> under win32.
>
>
>  Thanks in advance.
>> (I will read the the fixes to the doc is in SVN as soon as possible.)
>>
>
> 2.0.1 will have it, and should be out before Christmas.
>
>
>
>> 2008/12/16 Laurent Gautier <lgaut...@gmail.com <mailto:lgaut...@gmail.com
>> >>
>>
>>
>>    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
>>        <mailto:rpy-list@lists.sourceforge.net>
>>        https://lists.sourceforge.net/lists/listinfo/rpy-list
>>
>>
>>
>>
>>
>> --
>> Marcos F. Silva
>> http://marcosfs2006.googlepages.com
>>
>
>


-- 
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

Reply via email to