Re: [R] selecting ith rows of a matrix

2009-04-29 Thread Philipp Pagel
On Wed, Apr 29, 2009 at 01:58:06PM +0530, 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. Others ahve alr

Re: [R] selecting ith rows of a matrix

2009-04-29 Thread Umesh Srinivasan
Thanks a lot Baptiste & Dimitris, It's working! Cheers, Umesh On Wed, Apr 29, 2009 at 2:06 PM, Dimitris Rizopoulos < d.rizopou...@erasmusmc.nl> wrote: > 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

Re: [R] selecting ith rows of a matrix

2009-04-29 Thread Dimitris Rizopoulos
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/ dat

Re: [R] selecting ith rows of a matrix

2009-04-29 Thread baptiste auguie
Try this, a = matrix(rnorm(10*10),ncol=10) a[, seq(1,ncol(a),by=2)] baptiste On 29 Apr 2009, at 09:28, 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 mat

[R] selecting ith rows of a matrix

2009-04-29 Thread Umesh Srinivasan
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]] __