The problem is your loop condition. For example, when i reaches (n-3), a[i + 5, ] is out of bounds.
-k On Thu, Oct 8, 2009 at 4:14 PM, Ashta <sewa...@gmail.com> 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? > > [[alternative HTML version deleted]] > > ______________________________________________ > R-help@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. > [[alternative HTML version deleted]] ______________________________________________ R-help@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.