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 the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.