World Bank Population living in slums data analysis 6 - Hierarchical Clustering using R

Generated by Bing Image Creator: Unique landscape view traditional Japanese local area with rape blossoms, photo


This post is followong of the above post. In this post I will do hierarchical clustering using R.

First I make a matrix object for hierarchical clustering.

I will use two variables, sulums_2000 and change for clustetring.

Next, I make a function for scaling.

Then, I use maxmin() function to re-scale variables.

Let's see summary of mtx.

You'll see the both variables are re-scaled, max is 1, minimum is 0.

Now, let's do hierarchical clustering.

I use dist() function to calculate distance.

Then, I use hclust() function to make hierarchical clustering.

Let's plot dendrogram plot.

From the above plot, I think it is better divde three clusters like below plot.

I use cutree() function to assign those clusters to each country.

Finally, I make a scatter plot with the three clusters.

I see three clusters are very clearly divided.

That's it. Thank you!


To read from the first post,