[R] error : subscript out of bounds

jim holtman jholtman at gmail.com
Tue May 25 21:43:11 CEST 2010


Take a look at what happens when k=947 (last time through the loop).
You are then indexing 'm in 948:947' so m==948 which is outside your
matrix.

On Tue, May 25, 2010 at 2:49 PM, Ayesha Khan
<ayesha.diamondash at gmail.com> wrote:
> Hi,
>
> I'm trying to calculate euclidean distance for my matrix rx1.  Its a big
> matrix with 947 elements. However when i do the following,
>
> for(k in 1:947) for(m in (k+1):947){
> A =rbind(A,c(k,m,ED(rx1[,k], rx1[,m])))
> }
> I get the following error:
> ED(rx1[,k], rx1[,m]) : subscript out of bounds
>
> I checked for k in 1:100 and it runs fine; its a huge matrix and takes
> atleast an hour to run before I get the results so I dont wanna run the
> whole thing again and get the same error. Please help!
>
>
> --
> Ayesha Khan
>
> MS Bioengineering
> Dept. of Bioengineering
> Rice University, TX
>
>        [[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.
>



-- 
Jim Holtman
Cincinnati, OH
+1 513 646 9390

What is the problem that you are trying to solve?



More information about the R-help mailing list