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 <lgaut...@gmail.com> wrote:
> http://rpy.sourceforge.net/rpy2/doc-2.2/html/vector.html#extracting
>
> Best,
>
>
> L.
>
>
>
> On 2012-02-24 18:26, Niek de Klein wrote:
>
> Hi,
>
> I want to do the same thing as in the R example found here:
> http://www.r-tutor.com/r-introduction/data-frame/data-frame-column-slice.
> He makes use of the mtcars datase which looks like this:
>
> mpg cyl disp hp drat wt ...
> Mazda RX4 21.0 6 160 110 3.90 2.62 ...
> Mazda RX4 Wag 21.0 6 160 110 3.90 2.88 ...
> Datsun 710 22.8 4 108 93 3.85 2.32 ...
>
> And then selects the mpg and hp column with an index vector
>
> > mtcars[c("mpg", "hp")]
> mpg hp
> Mazda RX4 21.0 110
> Mazda RX4 Wag 21.0 110
> Datsun 710 22.8 93
>
> It's simple to retrieve one row in rpy2, to get mpg in this case:
>
> import rpy2.robjects as R
> R.r['mtcars'][0]
>
> However, I don't know how to select two columns
>
> import rpy2.robjects as R
> R.r['mtcars'][R.vectors.IntVector([0,3])]
>
> Gives
>
> TypeError: 'IntVector' object cannot be interpreted as an index
>
> Just like every other vector that is in R.vectors (I tried them all)
>
> So my question comes down to, how can I get an index vector in rpy2, or if
> that doesn't exist, how can I select two columns?
>
> Thanks!
> Niek
>
>
> ------------------------------------------------------------------------------
> Virtualization & Cloud Management Using Capacity Planning
> Cloud computing makes use of virtualization - but cloud computing
> also focuses on allowing computing to be delivered as a
> service.http://www.accelacomm.com/jaw/sfnl/114/51521223/
>
>
>
> _______________________________________________
> rpy-list mailing
> listrpy-list@lists.sourceforge.nethttps://lists.sourceforge.net/lists/listinfo/rpy-list
>
>
>
------------------------------------------------------------------------------
Try before you buy = See our experts in action!
The most comprehensive online learning library for Microsoft developers
is just $99.99! Visual Studio, SharePoint, SQL - plus HTML5, CSS3, MVC3,
Metro Style Apps, more. Free future releases when you subscribe now!
http://p.sf.net/sfu/learndevnow-dev2
_______________________________________________
rpy-list mailing list
rpy-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/rpy-list