www.crosshyou.info

政府統計の総合窓口のデータや、OECDやUCIやのデータを使って、Rの練習をしています。ときどき、読書記録も載せています。

OECD Nutrient balance data analysis 5 - Hierarchical Clustering using R

Photo by Erda Estremera on Unsplash 

www.crosshyou.info

This post is following of above post.

Let's make two scatter plots and display them in a panel.

Firstly, I load gridExtra package.

Then, I make two objects, each object is for a scatter plot.

p1 object is like above.

p2 object is like above.

Then, I use grid.arrange() function.

Next, let's do hierarchial culstering. I use dist(), hsclust() and plot() function.

I see there are three clusters, one is CHN, BRA and IND, the other is JPN, CYP, KOR, MLT, BEL, NLD, DNK, HRV, VNM, CZE and FIN, and thr 3rd cluster is the rest.

Let's divide locations into three groups usung cutree() function.

Let's visualize it.

You see PC1 and PC2 are good for clustering.

That's it. Thank you!

 

Next post is

www.crosshyou.info

 

To read from the 1st post,

www.crosshyou.info