No subject


Thu Nov 16 16:52:29 CST 2006


R vectors are converted to python lists. It may make
more sense to convert them to an array (either stdlib
or scipy.base version) - without copying data if
possible.

R arrays and matrices are converted to Numeric arrays.
Eg

In [8]: r.array([1,2,3,4,5,6],dim=[2,3])
Out[8]:
array([[1, 3, 5],
       [2, 4, 6]])

However, column and row names (or dimnames for arrays
with >2 dimensions) are lost in R->Py conversion. I do
not know whether these conversions require copying of
the data.

R data-frames are currently converted to python
dictionaries and I don’t think that there is any
simple way to convert a python object to an R data
frame. This is the biggest limitation of rpy in my
opinion. 

In [16]:
r.data_frame(col1=[1,2,3,4],col2=['one','two','three','four'])
Out[16]: {'col2': ['one', 'two', 'three', 'four'],
'col1': [1, 2, 3, 4]}

If it were possible to convert between an R data-frame
and a scipy.base record array without copying or
losing data, RPy would become more useful.

I wish I understood C, scipy.base and R well enough to
give this a go. However, this is Way over my head! 

Mike 

--- Magnus Lie Hetland <magnus at hetland.org> wrote:
> I was just thinking about some experimental designs,
> and whether I
> could, perhaps, do the statistics in Python. I
> remembered having used
> RPy [1] briefly at some time (there may be other
> similar bindings out
> there -- I don't remember) and started thinking
> about whether I could,
> perhaps, combine it with numpy in some way. My first
> thought was to
> reimplement the relevant statistical functions; then
> I thought about
> how to convert data back and forth -- but then it
> occurred to me that
> R also uses arrays extensively, and that it could,
> perhaps, be
> possible to expose those (through something like
> RPy) through the
> array interface/protocol!
> 
> This would be (IMO) a good example of the benefits
> of the array
> protocol; it's not a matter of "getting yet another
> array module". RPy
> is an external library/language with *lots* of
> features that might be
> useful to numpy users, many of which aren't likely
> to be implemented
> in Python for quite a while, I'd guess (unless,
> perhaps, someone
> writes a translator from R, which I'm sure is
> doable).
> 
> I don't know enough (at least yet ;) about the
> implementation of RPy
> and the R library to say for sure whether this would
> even be possible,
> but it does seem like it could be really useful...
> 
> [1] rpy.sf.net
> 
> -- 
> Magnus Lie Hetland                    Fall seven
> times, stand up eight
> http://hetland.org                                 
> [Japanese proverb]
> 
> 
>
-------------------------------------------------------
> SF email is sponsored by - The IT Product Guide
> Read honest & candid reviews on hundreds of IT
> Products from real users.
> Discover which products truly live up to the hype.
> Start reading now.
>
http://ads.osdn.com/?ad_id=6595&alloc_id=14396&op=click
> _______________________________________________
> Numpy-discussion mailing list
> Numpy-discussion at lists.sourceforge.net
>
https://lists.sourceforge.net/lists/listinfo/numpy-discussion
> 

Find local movie times and trailers on Yahoo! Movies.
http://au.movies.yahoo.com




More information about the Numpy-discussion mailing list