Message-ID: <49F81183.5090605@erasmusmc.nl>
Date: 2009-04-29T08:36:19Z
From: Dimitris Rizopoulos
Subject: selecting ith rows of a matrix
In-Reply-To: <ffa653cd0904290128l1491f7b0ne0f4f71faa984527@mail.gmail.com>
probably you want to use seq(), e.g.,
mat <- matrix(1:500, 100, 5)
mat[seq(1, nrow(mat), 2), ]
mat[seq(1, nrow(mat), 3), ]
mat[seq(1, nrow(mat), 4), ]
I hope it helps.
Best,
Dimitris
Umesh Srinivasan wrote:
> Hi all,
>
> If I have a huge matrix/ dataframe and I want to create a new matrix/
> dataframe with every second (or third, or fourth etc.) row of the original
> matrix, how can I do it? Any help much appreciated.
>
> Thanks,
> Umesh
>
> [[alternative HTML version deleted]]
>
> ______________________________________________
> R-help at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>
--
Dimitris Rizopoulos
Assistant Professor
Department of Biostatistics
Erasmus University Medical Center
Address: PO Box 2040, 3000 CA Rotterdam, the Netherlands
Tel: +31/(0)10/7043478
Fax: +31/(0)10/7043014