On Wed, Jun 3, 2009 at 1:52 PM, Axel Kowald <axel.kow...@rub.de> wrote: > > Hi everybody, > > I'm using rpy 1.0.3 and R 2.7.0 under win XP and I have a problem to > produce an R matrix from python. > Here I'm creating a matrix and then test if the created object is indeed > a matrix. Unfortunately, I always get False :-( > > >>> erg = r.matrix(0.0,nrow=2,ncol=3) > >>> erg > [[0.0, 0.0, 0.0], [0.0, 0.0, 0.0]] > >>> r.is_matrix(erg) > False > >>> r.is_matrix(r.as_matrix(erg)) > False > > Any idea what's wrong ?? > > Many thanks, > > Axel
This isn't on the rpy FAQ page, but it should be! http://rpy.sourceforge.net/faq.html Without seeing the rest of the code this is only a guess, but I would suggest your R matrix objects are being automatically being converted into python objects (which is lossy), and then when you pass them back to R they are re-converted into something not quite the same (probably an array for some sort). See: http://rpy.sourceforge.net/rpy/doc/rpy_html/Conversion-system.html Try something like this: import rpy rpy.set_default_mode(rpy.NO_CONVERSION) #your code here #If you want to go back to the default conversion, rpy.set_default_mode(rpy.BASIC_CONVERSION) Peter ------------------------------------------------------------------------------ OpenSolaris 2009.06 is a cutting edge operating system for enterprises looking to deploy the next generation of Solaris that includes the latest innovations from Sun and the OpenSource community. Download a copy and enjoy capabilities such as Networking, Storage and Virtualization. Go to: http://p.sf.net/sfu/opensolaris-get _______________________________________________ rpy-list mailing list rpy-list@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/rpy-list