[R] row selection
Bernardo Rangel Tura
tura at centroin.com.br
Sun Oct 11 12:32:21 CEST 2009
On Thu, 2009-10-08 at 16:14 -0400, Ashta wrote:
> Hi all,
> I have a matrix named x with N by C
> I want to select every 5 th rrow from matrix x
> I used the following code
> n<- nrow(x)
> > for(i in 1: n){
> + b <- a[i+5,]
> >b
> }
> Error: subscript out of bounds
>
> Can any body point out the problem?
Hi Ashta,
If I understand your request you need select row 5,10,15, ...
In this case you can use this script:
x[1:nrow(n)%%5==0]
--
Bernardo Rangel Tura, M.D,MPH,Ph.D
National Institute of Cardiology
Brazil
More information about the R-help
mailing list