I am using the package spatstat. I have a data frame of coordinates that I have divided into two sets, healthy(Mark=no) and diseased(Mark=yes). I am able to find the distance between the diseased point and all of the other points:
>D<-crossdist(diseased,healthy)
But now I need to remark my points based on the distances they are from the diseased point, sort of like:
>i<-length(D)
>for n=1:i,
> if D[n]<1,
> mark(n)<-yes,
> else,
> mark(n)<-no,
> end
>end
I am new to using loops in R, and I was never really good at it in Matlab, I am still going through all of the help guides, but any tips on how to do this would be very helpful.
D looks like:
> 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