O'Reilly logo

R Data Analysis Cookbook - Second Edition by Kuntal Ganguly

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

How it works...

Instead of taking the full dataset, the CLARA algorithm randomly chooses a small sample of the actual data as a representative of the data. Medoids are then calculated from this sample using PAM.

In this example, we first apply the CLARA algorithm using the clara() function from the cluster package on the scaled protein intake data frame. Then we check the four cluster medoids using the fitted CLARA model and finally visualize the cluster plot using fviz_cluster() from the factoextra package.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required