R: finding line in matrix with points close to two selected points.
I have a matrix with long/lat for an area. And I have a point in this area with a longitude and latitude, so I need to find the point in the matrix that is the best match.
I have tried this, but it is not working:
find.point <- is.numeric(which(abs(matrix[,1]-East)==min(abs(matrix[,1]-East)))
&& which(abs(matrix[,2]-North)==min(abs(matrix[,2]-North))))
How to find the point where East is closest to matrix[,1] and also North closest to matrix[,2]?