This only shows how to extract 1 row, 1 column or 1 element. I want to get
2 columns out of a matrix and save that in a new matrix.
Kind regards,
Niek
On Fri, Feb 24, 2012 at 6:38 PM, Laurent Gautier wrote:
> http://rpy.sourceforge.net/rpy2/doc-2.2/html/vector.html#extracting
>
> Best,
>
>
> L
If someone else wants to know, this works:
import rpy2.robjects as R
vec1 = R.r['mtcars'][0]
vec2 = R.r['mtcars'][1]
m = R.r.matrix(R.r['append'](vec1,vec2), nrow=R.r['length'](vec1))
But I'm still wondering if there is a more direct approach, or if there is
a way to use index vec
The intended message is that R-style indexing can be achieved by
appending .rx to the variable name, before the "[" operator. It would
then work like just like it would in R.
Example:
# first and third columns
m_subset = mtcars.rx[True, IntVector((1,3))]
Best,
Laurent
On 2012-02-27 11:0