I got caught out converting a 3d array in R to a numpy array. I did
something like:

import numpy
import rpy2
import rpy2.robjects as robjects

marr = robjects.r.array(robjects.IntVector(range(54)),dim=
robjects.IntVector([9,2,3]))
marrpy = numpy.array(marr)
print marrpy.flatten()
print robjects.r['as.vector'](marr)

Which clearly doesn't work (at least for me, using rpy2.1.7, R-10.0 on
64bit suse linux). The matrix version does work, eg

mat = robjects.r.matrix(robjects.IntVector(range(54)),nrow=9)
matpy = numpy.array(mat)
print mat
print matpy

I checked the documentation, and found examples for vectors and
matrices, but not for arrays, but also no warnings. So, I was just
wondering, is this supposed to work? If it is, a hint on why it doesn't
work for me would be good. If it isn't supposed to work, I was wondering
if it were possible to throw an error or something.

Regards,
Robert

 
 
Robert Denham
Environmental Statistician, Remote Sensing Centre
Environment and Resource Sciences
Phone 07 3896 9899 (ext 69899) 
Email: robert.den...@derm.qld.gov.au
www.derm.qld.gov.au <http://www.derm.qld.gov.au/> 
 
Department of Environment and Resource Management
QCCE Building, 80 Meiers Rd, Indooroopilly QLD 4068


+----------------------------------------------------------------+
Think B4U Print
1 ream of paper = 6% of a tree and 5.4kg CO2 in the atmosphere
3 sheets of A4 paper = 1 litre of water
+----------------------------------------------------------------+


------------------------------------------------------------------------------
Nokia and AT&T present the 2010 Calling All Innovators-North America contest
Create new apps & games for the Nokia N8 for consumers in  U.S. and Canada
$10 million total in prizes - $4M cash, 500 devices, nearly $6M in marketing
Develop with Nokia Qt SDK, Web Runtime, or Java and Publish to Ovi Store 
http://p.sf.net/sfu/nokia-dev2dev
_______________________________________________
rpy-list mailing list
rpy-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/rpy-list

Reply via email to