我正在使用library("dbscan")
以纬度和经度对地理数据进行聚类。我想知道哪个坐标[纬度,经度]属于R中的哪个簇。有没有办法检索每个簇下的原始数据点?
例如:
纬度= c(60.95886,63.04287,60.79435,61.79435,64.79435,61.95886,65.04287,66.79435,63.79435,65.79435,66.79435,68.79435,69.79435)
经度= c(27.79045,22.87444,24.51007,23.49429,23.49429,28.79045,23.87444,26.51007,25.49429,26.49429,26.49429,29.49429,30.49429)
testData = data.frame(纬度,经度)
clust< - dbscan(testData,eps = 1.5,minPts = 3)
clust
DBSCAN clustering for 13 objects.
Parameters: eps = 1.5, minPts = 3
The clustering contains 2 cluster(s) and 7 noise points.
0 1 2
7 3 3
在这里,我想知道属于集群1和2的 testData 的数据点
答案 0 :(得分:0)
将dbscan的输出添加到初始data.frame。
testData$cluster = clust$cluster