我已经根据纬度和经度距离对数据集进行了聚类,并使用了cutree函数来确定每个唯一的纬度和经度所属的聚类。我的输出显示为here。 AL ######是唯一ID,其下方的数字是其群集。现在,我需要将这些结果链接回我的原始数据集。另一个问题是,由于某种原因,存储我的美眉结果的变量是int类,如果我将其更改为数据框,它将不起作用。任何熟悉角皮或知道如何解决此问题的人?谢谢。
CoastList <- list()
for(i in names(table(CoastHurricanes$ID))){
Newtemp <- CoastHurricanes[CoastHurricanes$ID == i, c("Latitude","Longitude")]
CoastList[[i]] <- as.data.frame(Newtemp)
}
Coast.dist.mat <- dist(x = CoastList, method = "DTW")
HurricaneTaxonomy <- hclust(Coast.dist.mat)
plot(clusters)
memb <- cutree(HurricaneTaxonomy, 10)
CoastHurricanes$ClusterGroup <- NA
library(dplyr)
CoastHurricanes <- CoastHurricanes %>% mutate(ClusterGroup = memb)