我正在使用包 spatstat。我有一个坐标数据框,我分为两组,健康(Mark=no)和患病(Mark=yes)。我能够找到病变点与所有其他点之间的距离:
>D<-crossdist(diseased,healthy)
但是现在我需要根据它们与患病点的距离来评论我的点,有点像:
>i<-length(D)
>for n=1:i,
> if D[n]<1,
> mark(n)<-yes,
> else,
> mark(n)<-no,
> end
>end
我是在 R 中使用循环的新手,在 Matlab 中我从来没有真正擅长它,我仍在阅读所有帮助指南,但任何关于如何做到这一点的提示都会非常有帮助。
D 看起来像:
> D
[,1] [,2] [,3] [,4] [,5] [,6] [,7] [,8]
[1,] 0.4796548 5.906068 6.061941 5.837476 5.62358 5.196297 7.687075 1.740198
[,9] [,10] [,11] [,12] [,13] [,14] [,15] [,16]
[1,] 2.760947 8.921383 10.64188 8.385258 6.788703 6.542282 8.631057 11.19689
[,17] [,18] [,19] [,20] [,21] [,22] [,23] [,24]
[1,] 11.38957 11.16738 10.88189 10.48931 9.116005 7.757465 7.907191 8.453458
[,25] [,26] [,27] [,28] [,29] [,30] [,31] [,32]
[1,] 7.072456 6.89453 8.900875 8.613843 8.569073 11.82978 11.68813 9.27332
[,33] [,34] [,35] [,36] [,37] [,38] [,39]
[1,] 9.318501 9.64491 9.264779 9.357388 9.488624 10.57165 9.173374