I'm still new to rpy/R and came across a behavior that get's me confused 
and that in my opinion is a bit inconsistent.

I've been trying understand how I can manipulate different R objects as 
python objects and came across something that I'm not sure if it's 
supposed to happen.

 >>> a = r.array([[1],[2]])
 >>> b = r.array([[1,2],[2,3]])
 >>> a
array([ 1.,  2.])

 >>> b
[[1, 2], [2, 3]]

 >>> type(a)
<type 'numpy.ndarray'>

 >>> type(b)
<type 'list'>

Both data structures are lists of lists in python but are returned as 
array (as I would expect) but also as lists of lists as if untouched.

This became a problem when checking the converted object in R:

 >>> r.is_array(a)
True
 >>> r.is_array(b)
False

I'm not sure if this is to be considered a problem, but the fact of not 
being consistent got me lost during the last couple of hours.

Is there any clean way to work around this problem?

I also tried using the array() function, but that got me an even more 
confused since:

 >>> c=array(b)
 >>> d=r.array(c)
 >>> r.is_array(c)
True

 >>> r.is_array(d)
True

 >>> r.print_(c)
     [,1] [,2]
[1,]    1    2
[2,]    2    3
array([[ 1.,  2.],
       [ 2.,  3.]])

 >>> r.print_(d)
[1] 1 2 2 3
array([ 1.,  2.,  2.,  3.])

 >>> r.library("gplots")
 >>> r.is_what(c)
['is.array', 'is.atomic', 'is.double', 'is.matrix', 'is.numeric', 'is.real']

 >>> r.is_what(d)
['is.array', 'is.atomic', 'is.double', 'is.numeric', 'is.real']

c and d are now both arrays, but have different structures, and now c is 
also matrix.

...
But this is probably my superficial knowledge on R

-------------------------------------------------------------------------
Check out the new SourceForge.net Marketplace.
It's the best place to buy or sell services for
just about anything Open Source.
http://sourceforge.net/services/buy/index.php
_______________________________________________
rpy-list mailing list
rpy-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/rpy-list

Reply via email to