Hello all, I am brand new to R and doing an exercise for a class. I need to find the nearest neighbour for points in the following matrix:
> DistanceMatrix x1 x2 x3 x4 x5 [1,] 0.000000 2.828427 1.581139 2.236068 2.000000 [2,] 2.828427 0.000000 1.581139 4.123106 2.000000 [3,] 1.581139 1.581139 0.000000 2.549510 2.121320 [4,] 2.236068 4.123106 2.549510 0.000000 4.123106 [5,] 2.000000 2.000000 2.121320 4.123106 0.000000 I am not sure how to go about this as my knowledge of R functions and syntax is very basic. Is there a way of going at it using the pmin function? Otherwise what would be a simple way of going about it? Sorry for posting such a basic question! I've looked at the help pages and other forums on the web but am truly stuck here. Thanks in advance for your help... Léa -- View this message in context: http://r.789695.n4.nabble.com/Nearest-neighbour-in-a-matrix-tp3845747p3845747.html Sent from the R help mailing list archive at Nabble.com. ______________________________________________ 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.