How it works...

In this recipe, we demonstrate various state-of-the-art approaches to validate the generated clusters. First, we load the European protein intake dataset and normalize it. Then, we use the NbClust() function to identify the optimal number of clusters from the scaled protein data frame. The parameter of the NbClust function, max.nc, refers to the maximum number of clusters; min.nc refers to the minimum number of clusters. We then plot the optimal number of clusters for the protein intake dataset, which turns out to be k=3. More information about the parameters of the NbClust function can be found at https://www.rdocumentation.org/packages/NbClust/versions/3.0/topics/NbClust.

You can try out different combination of parameters ...

Get R Data Analysis Cookbook - Second Edition now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.