0

I have a dataframe in R and I am trying to cluster points (lat,long). I'm thinking of using hclust (single linkage) or nearest neighbor. But is there any way that I can stop the clustering algorithm once the clusters are >10km apart? Basically, I want to put a stopping condition to the clustering so it doesn't keep going until it becomes one cluster. But I want to base it on how far apart clusters are, not cut tree value. Is there a way to code this in R?

df$Lat <- c(26.2,26.1,26,26.2,26.2,25.8,25.8)
df$Long <- c(83.9,84,83,84.2,84.3,82,82.1)

enter image description here

Kate
  • 35
  • 6
  • It's easier to help you if you include a simple [reproducible example](https://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example) with sample input and desired output that can be used to test and verify possible solutions. I'm not sure what you mean when you say you want to "stop the clustering algorithm" – MrFlick Oct 20 '20 at 04:44
  • Stopping criteria is a theme with many variants. For instance, if the criterion is Euclidean distance between clusters, what are you measuring? Distance between means, centroids, medoids? Maybe this is more appropriate for [Cross Validated](https://stats.stackexchange.com/). – Rui Barradas Oct 20 '20 at 06:13
  • I'm going for minimum distance between groups of clusters so based on hclust single linkage – Kate Oct 20 '20 at 17:11

0 Answers0