Number of individuals in a cluster

Skip to first unread message

Claudia Macleay

Aug 5, 2021, 2:08:04 AM8/5/21
to FactoMineR users

What would the code be to determine the number of individuals in each cluster? In the tutorial using the Temperatures in European countries data set (used in the clustering course) in Cluster 1 there are 6 cities, in Cluster 2 there are 13 cities and in 4 cities in cluster 3. This is easy as I could count them but for my data set I have over 2000 rows.

Kind Regards 

Claudia Macleay  

Pierre de Larminat

Aug 5, 2021, 2:22:33 AM8/5/21
to FactoMineR users
Hi Claudia, 
if you have created the object aaa containing the results of the classification (e.g aaa <- FactoMineR::HCPC(my_data) ), you can access the individuals and their clusters in aaa$data.clust, which is a data.frame
You can apply dplyr::count(aaa$data.clust, clust) to get the size of each cluster.
Kind regards,
Reply all
Reply to author
0 new messages