[Tutor] Python and rpy
Kent Johnson
kent37 at tds.net
Mon Dec 25 03:05:20 CET 2006
Geoframer wrote:
> As i stated i think the conversion from Python to R is going wrong, but
> i have no clue on how to properly address that.
I agree. If you have Numeric installed (which I do) then r.diag() should
return a Numeric array, not a list of lists. This looks like the same
problem discussed in this thread:
http://sourceforge.net/mailarchive/message.php?msg_id=15307721
which does not seem to have been resolved.
I don't want to get involved in the Rpy mailing list but I would suggest
posting a very simple question asking why the result of r.diag() is not
a Numeric array. Perhaps this will lead to a solution.
> The code snippet i was talking about is on page 15 and 16 of the rpy
> reference guide http://rpy.sourceforge.net/rpy/doc/rpy.pdf ; the
> examples just don't work and i am lacking enough python experience to
> see why :-S.
>
> What i'm trying to do now is :
>
> ----
> from rpy import *
>
> class Test:
> def as_r(self):
> return [[1,2,3,4,5],[2,3,4,5,1],[3,4,5,1,2],[4,5,1,2,3],[5,1,2,3,4]]
>
> if __name__ == "__main__":
> a=with_mode(NO_CONVERSION, Test)()
> r.kmeans(a, 2, 5, 10, "Forgy")
I don't see how this will help. My understanding is that as_r() should
return an Robj, not a Python object. I think this code is the same as
passing a list of lists directly to kmeans.
Kent
More information about the Tutor
mailing list