R 中的可视化集群(使用 apcluster)

visualization clusters in R (using apcluster)

我需要通过模板可视化我的集群。 我的意思是,这是我的数据。

mydat<- read.csv("mydat.csv",sep=";", dec=",")

输入

  structure(list(x1 = c(0L, 0L, 1L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 
    0L, 0L, 1L, 1L, 1L, 1L, 1L, 1L, 0L, 0L, 0L), x2 = c(0L, 0L, 0L, 
    0L, 1L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 1L, 1L, 1L, 1L, 1L, 1L, 0L, 
    0L, 0L), x3 = c(0L, 0L, 1L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 
    0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L), x4 = c(0L, 0L, 0L, 0L, 0L, 
    0L, 0L, 0L, 0L, 1L, 0L, 0L, 0L, 0L, 0L, 1L, 0L, 1L, 0L, 0L, 0L
    ), x5 = c(0L, 0L, 0L, 0L, 0L, 1L, 0L, 0L, 1L, 0L, 0L, 0L, 0L, 
    0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L), x6 = c(0L, 0L, 0L, 0L, 0L, 0L, 
    0L, 0L, 0L, 0L, 0L, 0L, 0L, 1L, 0L, 0L, 0L, 1L, 1L, 1L, 1L), 
        x7 = c(0L, 0L, 0L, 0L, 0L, 0L, 0L, 1L, 0L, 0L, 1L, 0L, 0L, 
        0L, 0L, 0L, 0L, 1L, 1L, 1L, 1L), x8 = c(0L, 0L, 0L, 0L, 0L, 
        0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 1L, 0L, 0L, 
        0L)), .Names = c("x1", "x2", "x3", "x4", "x5", "x6", "x7", 
    "x8"), class = "data.frame", row.names = c(NA, -21L))

我进行了聚类分析

library("apcluster")
apres1 <- apclusterK(negDistMat(r=2), df, K=25)
apres1

我如何可视化结果,集群显示如下图所示

为 Ken.S 编辑 我试过了

plot(apres1, mydat)

但是可视化不适合我

我不想有 25 个地块,我想要 1 个地块,就像我执行分类一样

Select 您要绘制的 2 列。

library("apcluster")
for(i in 1:3)
{
x11()
m=i
n=i+1
mehul= iris[,c(m,n)]
apres1 <- apclusterK(negDistMat(r=3),mehul,K=3)
plot(apres1,mehul)
}