[R] selecting ith rows of a matrix
Dimitris Rizopoulos
d.rizopoulos at erasmusmc.nl
Wed Apr 29 10:36:19 CEST 2009
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
More information about the R-help
mailing list