我有以下代码:
afs_in_sound <- stringdistmatrix(soundexcode_termen, soundexcode_termen, method = 'hamming')
我的矩阵如下所示:
0 1 inf inf
1 0 0 inf
inf 0 0 inf
inf 0 inf 0
我想获取上三角矩阵中值为 0 的所有索引。所以这里我想要[2,3]。
你可以使用这个:
which(upper.tri(afs_in_sound) & afs_in_sound==0, arr.ind=TRUE)
这使 :
row col
[1,] 2 3
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)