Dear Ben,
I was searching for the same problem. Thank you very much, it helped me a lot 
and I will use it quite often!

In addition to the problem given by tintin_et_milou. I have to compare a two 
pairs of vectors.

I.e. I have two datasets each with latitude and longitude (which defines the 
geographical position of data points.)
As you might imagine, it is meaningful to take into account both latitude and 
longitude, when searching for the nearest data point from the otehr dataset.

Do you have any idea how to do this efficiently (actually I used loops ;-( ?
Best regards
Daniel


Ben Bolker schrieb:
> 
> distfun <- function(x1,x2) { (x1-x2)^2 }
> 
> outer(m1[,1],y,distfun)

>   cheers
>     Ben

______________________________________________
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Reply via email to