0

x と y が空間座標である大規模な空間データセットでクラスター分析を行っています。hclust と dynamicTreeCut を使用しており、表現のために ggplot を使用して散布図を表示しています。

しかし、カットは行または列でしか表示できないため、クラスターを正しく視覚化できません。

これは私が欲しいもののおもちゃのサンプルですが、私のデータでは、クラスターは水平方向にのみ機能します (したがって、y に対してのみクラスター化または視覚化する必要があると思います)。

# x and y are coordinates of points in a map

x <- sample(1:1000, 80)
y <- sample(1:1000, 80)

df <- data.frame(x,y)

hc <- hclust(dist(df, "euclidean"),"complete");

maxCoreScatter <- 0.81
minGap <- (1 - maxCoreScatter) * 3/4
groups <- cutreeDynamic(hc, minClusterSize=1, method="hybrid", distM=as.matrix(dist(df)), deepSplit=4, maxCoreScatter=maxCoreScatter, minGap=minGap)
df$group <- groups

p <- ggplot(df, aes(x,y,colour=factor(groups))) + geom_point() + theme(aspect.ratio = 1)
p
4

0 に答える 0