Two level loop over a matrix's row in R -


i need convert iteration below matrix operation.

a = certain_matrix(3,5) mat = matrix(0, 3,3)  ( in 1:3 )   ( j in 1:3 )     mat[i,j] = certain_distance(a[i,], a[j,]) 

roughly need use apply(). however, cannot hold of row index in

apply(a, 1, function(x) xxx) 

so how perform operation fast?


Comments

Popular posts from this blog

image - ClassNotFoundException when add a prebuilt apk into system.img in android -

I need to import mysql 5.1 to 5.5? -

Java, Hibernate, MySQL - store UTC date-time -