On Wed, May 18, 2011 at 12:24 PM, kcrisman <kcris...@gmail.com> wrote:
> On the page you linked to:
> "This the documentation for what will be soon the older version of
> rpy2. Do consider the upcoming 2.1.x releases if you are starting a
> project now."
>
> If you look at http://rpy.sourceforge.net/rpy2/doc-2.2/html/changes.html
> it also seems like in higher-numbered releases there are changes in
> this functionality.  Maybe this is a known bug; can you try
>
> from rpy2.robjects.numpy2ri import numpy2ri
> ro.conversion.py2ri = numpy2ri
>
> as on the 2.2 documentation and see if that works.

Nope, not at all.

> That said, I never use it - I always use the Sage pexpect interface to
> R.  But now I will bookmark this worksheet if I get the chance to give
> another R/Sage talk!

The Sage pexpect is slow and brittle if the size of data you need to
move into or out of R is large.  The rpy2 interface is much more
robust in this regard.
But rpy2 is also somewhat weird and wacky, as I learned today.


Maybe we need to upgrade the rpy2 in Sage...

William


>
> On May 18, 2:14 pm, William Stein <wst...@gmail.com> wrote:
>> Hi,
>>
>> I was preparing a lecture [1] on rpy2 [2] in Sage (version 4.6.2) and notice
>> that the following very important central bit of rpy2 functionality --
>> namely converting a numpy array to R -- seems to be horribly broken:
>>
>> sage: import rpy2.robjects as robjects      # standard
>> sage: import rpy2.robjects.numpy2ri         # enable automatic
>> conversion from numpy to R
>> sage: import numpy                                   # make numpy available
>> sage: print robjects.r(numpy.array([1,2,3], dtype=float))       # try
>> it out; sad result.
>> [1] 3
>>
>> The output *should* be a vector with 3 entries, I think.
>> There are similar problems with numpy arrays.
>>
>> The same problem happens with 4.7.rc1.
>>
>> I've never used rpy2 seriously before now, so if I'm just confused,
>> can somebody who knows rpy2 better let me know.
>>
>>  -- William
>>
>> [1]  http://flask.sagenb.org/home/pub/57/
>> [2]http://rpy.sourceforge.net/rpy2/doc-2.0/html/numpy.html
>>
>> --
>> William Stein
>> Professor of Mathematics
>> University of Washingtonhttp://wstein.org
>
> --
> To post to this group, send an email to sage-devel@googlegroups.com
> To unsubscribe from this group, send an email to 
> sage-devel+unsubscr...@googlegroups.com
> For more options, visit this group at 
> http://groups.google.com/group/sage-devel
> URL: http://www.sagemath.org
>



-- 
William Stein
Professor of Mathematics
University of Washington
http://wstein.org

-- 
To post to this group, send an email to sage-devel@googlegroups.com
To unsubscribe from this group, send an email to 
sage-devel+unsubscr...@googlegroups.com
For more options, visit this group at http://groups.google.com/group/sage-devel
URL: http://www.sagemath.org

Reply via email to