简体   繁体   中英

visualization clusters in R (using apcluster)

I need get visualization of my clusters, but by template. i mean, here my data.

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

dput

  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))

i performed cluster analysis

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

How can i visualize the result, that clusters were displayed like in this picture 在此处输入图片说明

edited for Ken.SI tried do so

plot(apres1, mydat)

but the visualization is not suit me 在此处输入图片说明

i dont't want have 25 plots, i want have 1 plot, like if i perform classification

Select 2 column that you wanted to plot.

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)
}

在此处输入图片说明

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM