[R] Sampling the Distance Matrix

Lorenzo Isella lorenzo.isella at gmail.com
Fri Sep 25 21:54:33 CEST 2015


Apologies for not letting this thread rest in peace.
The small script

#########################################################
set.seed(1234)

x <- rnorm(20)
y <- rnorm(20)


goodcls <- apply(mtxcomb , 2, function(idx) all( dist( cbind( x[idx],
y[idx]) ) > 0.9))

mycomb <- mtxcomb [ , goodcls]
#########################################################


is perfect to detects groups of 5 points whose distances to each other
are always above 0.9.
However, in my practical case I have about 500 points and I am looking
for subset of several tens of points whose distance is above a given
threshold.
Unfortunately, the approach above does not scale, so I wonder if
anybody is aware of an alternative approach.
Many thanks

Lorenzo



More information about the R-help mailing list