Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我需要将下面的迭代转换为矩阵运算。
a = certain_matrix(3,5) mat = matrix(0, 3,3) for ( i in 1:3 ) for ( j in 1:3 ) mat[i,j] = certain_distance(a[i,], a[j,])
大致我需要使用 apply()。但是,我无法掌握行索引
apply(a, 1, function(x) XXX)
那么如何快速执行该操作呢?