[R] error : subscript out of bounds

Jannis bt_jannis at yahoo.de
Wed May 26 00:05:37 CEST 2010


just a guess as i do not have your data:
with k=947 (last outer loop) m starts from 948 and runs backwards to 
947. As your matrix probably only has 947 columns you get this error....

Ayesha Khan schrieb:
> 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!
>
>
>



More information about the R-help mailing list