There's more...

You can choose a different distance measure and method while performing hierarchical clustering. For more details, you can refer to the documents for dist and hclust:

> ? dist
> ? hclust  

In this recipe, we use hclust to perform agglomerative hierarchical clustering; if you would like to perform divisive hierarchical clustering, you can use the diana function:

  1. First, you can use diana to perform divisive hierarchical clustering:
        > dv = diana(customer, metric = "euclidean")  
  1. Then, you can use summary to obtain the summary information:
        > summary(dv) 
  1. Lastly, you can plot a dendrogram and banner with the plot function:
        > plot(dv)  

If you are interested in drawing a horizontal dendrogram, you can use the dendextend package. Use the following procedure to generate a horizontal dendrogram:

  1. First, install and load the dendextend and magrittr packages (if your R version is 3.1 or higher, you do not have to install and load the magrittr package):
        > install.packages("dendextend")
        > library(dendextend)
        > install.packages("margrittr")
        > library(magrittr)
  1. Set up the dendrogram:
        > dend = customer %>% dist %>% hclust %>% as.dendrogram
  1. Finally, plot the horizontal dendrogram:
        dend %>% plot(horiz=TRUE, main = "Horizontal Dendrogram")   
The horizontal dendrogram
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset