<div>
<p><br></p>
<p><a href="http://www.sthda.com/english/rpkgs/factoextra"><strong>factoextra</strong></a> is an R package making easy to extract and visualize the output of exploratory <strong>multivariate data analyses</strong>, including:</p>
<ol><li><p><a href="http://www.sthda.com/factominer-and-factoextra-principal-component-analysis-visualization-r-software-and-data-mining">Principal Component Analysis (PCA)</a>, which is used to summarize the information contained in a continuous (i.e, quantitative) multivariate data by reducing the dimensionality of the data without loosing important information.</p></li>
<li><p><a href="http://www.sthda.com/correspondence-analysis-in-r-the-ultimate-guide-for-the-analysis-the-visualization-and-the-interpretation-r-software-and-data-mining">Correspondence Analysis (CA)</a>, which is an extension of the principal component analysis suited to analyse a large contingency table formed by two qualitative variables (or categorical data).</p></li>
<li><p><a href="http://www.sthda.com/multiple-correspondence-analysis-essentials-interpretation-and-application-to-investigate-the-associations-between-categories-of-multiple-qualitative-variables-r-software-and-data-mining">Multiple Correspondence Analysis (MCA)</a>, which is an adaptation of CA to a data table containing more than two categorical variables.</p></li>
<li><p><a href="http://www.sthda.com/english/rpkgs/factoextra/reference/fviz_mfa.html">Multiple Factor Analysis (MFA)</a> dedicated to datasets where variables are organized into groups (qualitative and/or quantitative variables).</p></li>
<li><p><a href="http://www.sthda.com/english/rpkgs/factoextra/reference/fviz_hmfa.html">Hierarchical Multiple Factor Analysis (HMFA)</a>: An extension of MFA in a situation where the data are organized into a hierarchical structure.</p></li>
<li><p><a href="http://www.sthda.com/english/rpkgs/factoextra/reference/fviz_famd.html">Factor Analysis of Mixed Data (FAMD)</a>, a particular case of the MFA, dedicated to analyze a data set containing both quantitative and qualitative variables.</p></li>
</ol><p>There are a number of R packages implementing principal component methods. These packages include: FactoMineR, ade4, stats, ca, MASS and ExPosition.</p>
<p>However, the result is presented differently according to the used packages. To help in the interpretation and in the visualization of multivariate analysis - such as cluster analysis and dimensionality reduction analysis - we developed an easy-to-use R package named <a href="http://www.sthda.com/english/rpkgs/factoextra">factoextra</a>.</p>
<br><div>
<ul><li><p>The R package <strong>factoextra</strong> has flexible and easy-to-use methods to extract quickly, in a human readable standard data format, the analysis results from the different packages mentioned above.</p></li>
<li><p>It produces a <strong>ggplot2</strong>-based <strong>elegant data visualization</strong> with less typing.</p></li>
<li>It contains also many functions facilitating clustering analysis and visualization.</li>
</ul></div>
<p><br></p>
<div>
<p>We’ll use i) the FactoMineR package (Sebastien Le, et al., 2008) to compute PCA, (M)CA, FAMD, MFA and HCPC; ii) and the factoextra package for extracting and visualizing the results.</p>
<p>FactoMineR is a great and my favorite package for computing principal component methods in R. It’s very easy to use and very well documented. The official website is available at: <a href="http://factominer.free.fr/">http://factominer.free.fr/</a>. Thanks to <a href="http://math.agrocampus-ouest.fr/infoglueDeliverLive/membres/Francois.Husson">François Husson</a> for his impressive work.</p>
</div>
<p><span>The figure below shows methods, which outputs can be visualized using the factoextra package. The official online documentation is available at: <a href="http://www.sthda.com/english/rpkgs/factoextra">http://www.sthda.com/english/rpkgs/factoextra</a>. </span></p>
<p></p>
<br><div>
<strong>Contents</strong>
<ul><li><a href="http://www.sthda.com/#why-using-factoextra">Why using factoextra?</a></li>
<li><a href="http://www.sthda.com/#installing-factominer">Installing FactoMineR</a></li>
<li><a href="http://www.sthda.com/#installing-and-loading-factoextra">Installing and loading factoextra</a></li>
<li><a href="http://www.sthda.com/#main-functions-in-the-factoextra-package">Main functions in the factoextra package</a><ul><li><a href="http://www.sthda.com/#visualizing-dimension-reduction-analysis-outputs">Visualizing dimension reduction analysis outputs</a></li>
<li><a href="http://www.sthda.com/#extracting-data-from-dimension-reduction-analysis-outputs">Extracting data from dimension reduction analysis outputs</a></li>
<li><a href="http://www.sthda.com/#clustering-analysis-and-visualization">Clustering analysis and visualization</a></li>
</ul></li>
<li><a href="http://www.sthda.com/#dimension-reduction-and-factoextra">Dimension reduction and factoextra</a><ul><li><a href="http://www.sthda.com/#principal-component-analysis">Principal component analysis</a></li>
<li><a href="http://www.sthda.com/#correspondence-analysis">Correspondence analysis</a></li>
<li><a href="http://www.sthda.com/#multiple-correspondence-analysis">Multiple correspondence analysis</a></li>
<li><a href="http://www.sthda.com/#advanced-methods">Advanced methods</a></li>
</ul></li>
<li><a href="http://www.sthda.com/#cluster-analysis-and-factoextra">Cluster analysis and factoextra</a><ul><li><a href="http://www.sthda.com/#partitioning-clustering">Partitioning clustering</a></li>
<li><a href="http://www.sthda.com/#hierarchical-clustering">Hierarchical clustering</a></li>
<li><a href="http://www.sthda.com/#determine-the-optimal-number-of-clusters">Determine the optimal number of clusters</a></li>
</ul></li>
<li><a href="http://www.sthda.com/#acknoweledgment">Acknoweledgment</a></li>
<li><a href="http://www.sthda.com/#references">References</a></li>
<li><a href="http://www.sthda.com/#infos">Infos</a></li>
</ul></div>
<div>
<h2>Why using factoextra?</h2>
<ol><li><p>The factoextra R package can handle the results of PCA, CA, MCA, MFA, FAMD and HMFA from several packages, for extracting and visualizing the most important information contained in your data.</p></li>
<li>After PCA, CA, MCA, MFA, FAMD and HMFA, the most important row/column elements can be highlighted using :
</li>
</ol><ul><li>their cos2 values corresponding to their quality of representation on the factor map</li>
<li>their contributions to the definition of the principal dimensions.</li>
</ul><p><span>If you want to do this, the factoextra package provides a convenient solution.</span></p>
<ol start="3"><li>PCA and (M)CA are used sometimes for prediction problems : one can predict the coordinates of new supplementary variables (quantitative and qualitative) and supplementary individuals using the information provided by the previously performed PCA or (M)CA. This can be done easily using the <a href="http://www.sthda.com/factominer-and-factoextra-principal-component-analysis-visualization-r-software-and-data-mining">FactoMineR</a> package.</li>
</ol><p><span>If you want to make predictions with PCA/MCA and to visualize the position of the supplementary variables/individuals on the factor map using ggplot2: then factoextra can help you. It’s quick, write less and do more…</span></p>
<ol start="4"><li>Several functions from different packages - FactoMineR, ade4, ExPosition, stats - are available in R for performing PCA, CA or MCA. However, The components of the output vary from package to package.</li>
</ol><p><span>No matter the package you decided to use, factoextra can give you a human understandable output.</span></p>
</div>
<div>
<h2>Installing FactoMineR</h2>
<p>The FactoMineR package can be installed and loaded as follow:</p>
<pre><code># Install
install.packages(&quot;FactoMineR&quot;)

# Load
library(&quot;FactoMineR&quot;)</code></pre>
</div>
<div>
<h2>Installing and loading factoextra</h2>
<ul><li>factoextra can be installed from <a href="https://cran.r-project.org/package=factoextra">CRAN</a> as follow:</li>
</ul><pre><code>install.packages(&quot;factoextra&quot;)</code></pre>
<ul><li>Or, install the latest version from <a href="https://github.com/kassambara/factoextra">Github</a></li>
</ul><pre><code>if(!require(devtools)) install.packages(&quot;devtools&quot;)
devtools::install_github(&quot;kassambara/factoextra&quot;)</code></pre>
<ul><li>Load factoextra as follow :</li>
</ul><pre><code>library(&quot;factoextra&quot;)</code></pre>
</div>
<div>
<h2>Main functions in the factoextra package</h2>
<p><span>See the online documentation (<a href="http://www.sthda.com/english/rpkgs/factoextra">http://www.sthda.com/english/rpkgs/factoextra</a>) for a complete list.</span></p>
<div>
<h3>Visualizing dimension reduction analysis outputs</h3>
<table><tr>Functions
Description
</tr><tr><td>fviz_eig (or fviz_eigenvalue)</td>
<td>Extract and visualize the eigenvalues/variances of dimensions.</td>
</tr><tr><td>fviz_pca</td>
<td>Graph of individuals/variables from the output of Principal Component Analysis (PCA).</td>
</tr><tr><td>fviz_ca</td>
<td>Graph of column/row variables from the output of Correspondence Analysis (CA).</td>
</tr><tr><td>fviz_mca</td>
<td>Graph of individuals/variables from the output of Multiple Correspondence Analysis (MCA).</td>
</tr><tr><td>fviz_mfa</td>
<td>Graph of individuals/variables from the output of Multiple Factor Analysis (MFA).</td>
</tr><tr><td>fviz_famd</td>
<td>Graph of individuals/variables from the output of Factor Analysis of Mixed Data (FAMD).</td>
</tr><tr><td>fviz_hmfa</td>
<td>Graph of individuals/variables from the output of Hierarchical Multiple Factor Analysis (HMFA).</td>
</tr><tr><td>fviz_ellipses</td>
<td>Draw confidence ellipses around the categories.</td>
</tr><tr><td>fviz_cos2</td>
<td>Visualize the quality of representation of the row/column variable from the results of PCA, CA, MCA functions.</td>
</tr><tr><td>fviz_contrib</td>
<td>Visualize the contributions of row/column elements from the results of PCA, CA, MCA functions.</td>
</tr></table></div>
<div>
<h3>Extracting data from dimension reduction analysis outputs</h3>
<table><tr>Functions
Description
</tr><tr><td>get_eigenvalue</td>
<td>Extract and visualize the eigenvalues/variances of dimensions.</td>
</tr><tr><td>get_pca</td>
<td>Extract all the results (coordinates, squared cosine, contributions) for the active individuals/variables from Principal Component Analysis (PCA) outputs.</td>
</tr><tr><td>get_ca</td>
<td>Extract all the results (coordinates, squared cosine, contributions) for the active column/row variables from Correspondence Analysis outputs.</td>
</tr><tr><td>get_mca</td>
<td>Extract results from Multiple Correspondence Analysis outputs.</td>
</tr><tr><td>get_mfa</td>
<td>Extract results from Multiple Factor Analysis outputs.</td>
</tr><tr><td>get_famd</td>
<td>Extract results from Factor Analysis of Mixed Data outputs.</td>
</tr><tr><td>get_hmfa</td>
<td>Extract results from Hierarchical Multiple Factor Analysis outputs.</td>
</tr><tr><td>facto_summarize</td>
<td>Subset and summarize the output of factor analyses.</td>
</tr></table></div>
<div>
<h3>Clustering analysis and visualization</h3>
<table><tr>Functions
Description
</tr><tr><td>dist(fviz_dist, get_dist)</td>
<td>Enhanced Distance Matrix Computation and Visualization.</td>
</tr><tr><td>get_clust_tendency</td>
<td>Assessing Clustering Tendency.</td>
</tr><tr><td>fviz_nbclust(fviz_gap_stat)</td>
<td>Determining and Visualizing the Optimal Number of Clusters.</td>
</tr><tr><td>fviz_dend</td>
<td>Enhanced Visualization of Dendrogram</td>
</tr><tr><td>fviz_cluster</td>
<td>Visualize Clustering Results</td>
</tr><tr><td>fviz_mclust</td>
<td>Visualize Model-based Clustering Results</td>
</tr><tr><td>fviz_silhouette</td>
<td>Visualize Silhouette Information from Clustering.</td>
</tr><tr><td>hcut</td>
<td>Computes Hierarchical Clustering and Cut the Tree</td>
</tr><tr><td>hkmeans (hkmeans_tree, print.hkmeans)</td>
<td>Hierarchical k-means clustering.</td>
</tr><tr><td>eclust</td>
<td>Visual enhancement of clustering analysis</td>
</tr></table></div>
</div>
<div>
<h2>Dimension reduction and factoextra</h2>
<p>As depicted in the figure below, the type of analysis to be performed depends on the data set formats and structures.</p>
<p></p>
<p>In this section we start by illustrating classical methods - such as PCA, CA and MCA - for analyzing a data set containing continuous variables, contingency table and qualitative variables, respectively.</p>
<p>We continue by discussing advanced methods - such as FAMD, MFA and HMFA - for analyzing a data set containing a mix of variables (qualitatives &amp; quantitatives) organized or not into groups.</p>
<p>Finally, we show how to perform hierarchical clustering on principal components (HCPC), which useful for performing clustering with a data set containing only qualitative variables or with a mixed data of qualitative and quantitative variables.</p>
<div>
<h3>Principal component analysis</h3>
<ul><li>Data: decathlon2 [in factoextra package]</li>
<li>PCA function: FactoMineR::PCA()</li>
<li>Visualization factoextra::fviz_pca()</li>
</ul><p><span>Read more about computing and interpreting principal component analysis at: <a href="http://www.sthda.com/factominer-and-factoextra-principal-component-analysis-visualization-r-software-and-data-mining"><strong>Principal Component Analysis</strong> (PCA)</a>.</span></p>
<ol><li><strong>Loading data</strong></li>
</ol><pre><code>library(&quot;factoextra&quot;)
data(&quot;decathlon2&quot;)
df </code></pre>
<ol start="2"><li><strong>Principal component analysis</strong></li>
</ol><pre><code>library(&quot;FactoMineR&quot;)
res.pca </code></pre>
<ol start="3"><li><strong>Extract and visualize eigenvalues/variances</strong>:</li>
</ol><pre><code># Extract eigenvalues/variances
get_eig(res.pca)</code></pre>
<pre><code>##        eigenvalue variance.percent cumulative.variance.percent
## Dim.1   4.1242133        41.242133                    41.24213
## Dim.2   1.8385309        18.385309                    59.62744
## Dim.3   1.2391403        12.391403                    72.01885
## Dim.4   0.8194402         8.194402                    80.21325
## Dim.5   0.7015528         7.015528                    87.22878
## Dim.6   0.4228828         4.228828                    91.45760
## Dim.7   0.3025817         3.025817                    94.48342
## Dim.8   0.2744700         2.744700                    97.22812
## Dim.9   0.1552169         1.552169                    98.78029
## Dim.10  0.1219710         1.219710                   100.00000</code></pre>
<pre><code># Visualize eigenvalues/variances
fviz_screeplot(res.pca, addlabels = TRUE, ylim = c(0, 50))</code></pre>
<div>
<p>
factoextra
</p>
</div>
<p>4.<strong>Extract and visualize results for variables</strong>:</p>
<pre><code># Extract the results for variables
var </code></pre>
<pre><code>## Principal Component Analysis Results for variables
##  ===================================================
##   Name       Description
## 1 &quot;$coord&quot;   &quot;Coordinates for the variables&quot;
## 2 &quot;$cor&quot;     &quot;Correlations between variables and dimensions&quot;
## 3 &quot;$cos2&quot;    &quot;Cos2 for the variables&quot;
## 4 &quot;$contrib&quot; &quot;contributions of the variables&quot;</code></pre>
<pre><code># Coordinates of variables
head(var$coord)</code></pre>
<pre><code>##                   Dim.1       Dim.2      Dim.3       Dim.4      Dim.5
## X100m        -0.8506257 -0.17939806  0.3015564  0.03357320 -0.1944440
## Long.jump     0.7941806  0.28085695 -0.1905465 -0.11538956  0.2331567
## Shot.put      0.7339127  0.08540412  0.5175978  0.12846837 -0.2488129
## High.jump     0.6100840 -0.46521415  0.3300852  0.14455012  0.4027002
## X400m        -0.7016034  0.29017826  0.2835329  0.43082552  0.1039085
## X110m.hurdle -0.7641252 -0.02474081  0.4488873 -0.01689589  0.2242200</code></pre>
<pre><code># Contribution of variables
head(var$contrib)</code></pre>
<pre><code>##                  Dim.1      Dim.2     Dim.3       Dim.4     Dim.5
## X100m        17.544293  1.7505098  7.338659  0.13755240  5.389252
## Long.jump    15.293168  4.2904162  2.930094  1.62485936  7.748815
## Shot.put     13.060137  0.3967224 21.620432  2.01407269  8.824401
## High.jump     9.024811 11.7715838  8.792888  2.54987951 23.115504
## X400m        11.935544  4.5799296  6.487636 22.65090599  1.539012
## X110m.hurdle 14.157544  0.0332933 16.261261  0.03483735  7.166193</code></pre>
<pre><code># Graph of variables: default plot
fviz_pca_var(res.pca, col.var = &quot;black&quot;)</code></pre>
<div>
<p>
factoextra
</p>
</div>
<p>It’s possible to control variable colors using their contributions (“contrib”) to the principal axes:</p>
<pre><code># Control variable colors using their contributions
fviz_pca_var(res.pca, col.var=&quot;contrib&quot;,
             gradient.cols = c(&quot;#00AFBB&quot;, &quot;#E7B800&quot;, &quot;#FC4E07&quot;),
             repel = TRUE # Avoid text overlapping
             )</code></pre>
<div>
<p>
factoextra
</p>
</div>
<ol start="5"><li><strong>Variable contributions to the principal axes</strong>:</li>
</ol><pre><code># Contributions of variables to PC1
fviz_contrib(res.pca, choice = &quot;var&quot;, axes = 1, top = 10)

# Contributions of variables to PC2
fviz_contrib(res.pca, choice = &quot;var&quot;, axes = 2, top = 10)</code></pre>
<div>
<p>
factoextra
</p>
</div>
<ol start="6"><li><strong>Extract and visualize results for individuals</strong>:</li>
</ol><pre><code># Extract the results for individuals
ind </code></pre>
<pre><code>## Principal Component Analysis Results for individuals
##  ===================================================
##   Name       Description
## 1 &quot;$coord&quot;   &quot;Coordinates for the individuals&quot;
## 2 &quot;$cos2&quot;    &quot;Cos2 for the individuals&quot;
## 3 &quot;$contrib&quot; &quot;contributions of the individuals&quot;</code></pre>
<pre><code># Coordinates of individuals
head(ind$coord)</code></pre>
<pre><code>##                Dim.1      Dim.2      Dim.3       Dim.4       Dim.5
## SEBRLE     0.1955047  1.5890567  0.6424912  0.08389652  1.16829387
## CLAY       0.8078795  2.4748137 -1.3873827  1.29838232 -0.82498206
## BERNARD   -1.3591340  1.6480950  0.2005584 -1.96409420  0.08419345
## YURKOV    -0.8889532 -0.4426067  2.5295843  0.71290837  0.40782264
## ZSIVOCZKY -0.1081216 -2.0688377 -1.3342591 -0.10152796 -0.20145217
## McMULLEN   0.1212195 -1.0139102 -0.8625170  1.34164291  1.62151286</code></pre>
<pre><code># Graph of individuals
# 1. Use repel = TRUE to avoid overplotting
# 2. Control automatically the color of individuals using the cos2
    # cos2 = the quality of the individuals on the factor map
    # Use points only
# 3. Use gradient color
fviz_pca_ind(res.pca, col.ind = &quot;cos2&quot;,
             gradient.cols = c(&quot;#00AFBB&quot;, &quot;#E7B800&quot;, &quot;#FC4E07&quot;),
             repel = TRUE # Avoid text overlapping (slow if many points)
             )</code></pre>
<div>
<p>
factoextra
</p>
</div>
<pre><code># Biplot of individuals and variables
fviz_pca_biplot(res.pca, repel = TRUE)</code></pre>
<div>
<p>
factoextra
</p>
</div>
<ol start="7"><li><strong>Color individuals by groups</strong>:</li>
</ol><pre><code># Compute PCA on the iris data set
# The variable Species (index = 5) is removed
# before PCA analysis
iris.pca </code></pre>
<div>
<p>
factoextra
</p>
</div>
</div>
<div>
<h3>Correspondence analysis</h3>
<ul><li>Data: housetasks [in factoextra]</li>
<li>CA function FactoMineR::CA()</li>
<li>Visualize with factoextra::fviz_ca()</li>
</ul><p><span>Read more about computing and interpreting correspondence analysis at: <a href="http://www.sthda.com/correspondence-analysis-in-r-the-ultimate-guide-for-the-analysis-the-visualization-and-the-interpretation-r-software-and-data-mining"><strong>Correspondence Analysis</strong> (CA)</a>.</span></p>
<ul><li><strong>Compute CA</strong>:</li>
</ul><pre><code> # Loading data
data(&quot;housetasks&quot;)

 # Computing CA
library(&quot;FactoMineR&quot;)
res.ca </code></pre>
<ul><li><strong>Extract results for row/column variables</strong>:</li>
</ul><pre><code># Result for row variables
get_ca_row(res.ca)

# Result for column variables
get_ca_col(res.ca)</code></pre>
<ul><li><strong>Biplot of rows and columns</strong></li>
</ul><pre><code>fviz_ca_biplot(res.ca, repel = TRUE)</code></pre>
<div>
<p>
factoextra
</p>
</div>
<p>To visualize only row points or column points, type this:</p>
<pre><code># Graph of row points
fviz_ca_row(res.ca, repel = TRUE)

# Graph of column points
fviz_ca_col(res.ca)

# Visualize row contributions on axes 1
fviz_contrib(res.ca, choice =&quot;row&quot;, axes = 1)

# Visualize column contributions on axes 1
fviz_contrib(res.ca, choice =&quot;col&quot;, axes = 1)</code></pre>
</div>
<div>
<h3>Multiple correspondence analysis</h3>
<ul><li>Data: <strong>poison</strong> [in factoextra]</li>
<li>MCA function <strong>FactoMineR::MCA</strong>()</li>
<li>Visualization <strong>factoextra::fviz_mca</strong>()</li>
</ul><p><span>Read more about computing and interpreting multiple correspondence analysis at: <a href="http://www.sthda.com/multiple-correspondence-analysis-essentials-interpretation-and-application-to-investigate-the-associations-between-categories-of-multiple-qualitative-variables-r-software-and-data-mining"><strong>Multiple Correspondence Analysis</strong> (MCA)</a>.</span></p>
<ol><li><strong>Computing MCA</strong>:</li>
</ol><pre><code>library(FactoMineR)
data(poison)
res.mca </code></pre>
<ol start="2"><li><strong>Extract results for variables and individuals</strong>:</li>
</ol><pre><code># Extract the results for variable categories
get_mca_var(res.mca)

# Extract the results for individuals
get_mca_ind(res.mca)</code></pre>
<ol start="3"><li><strong>Contribution of variables and individuals to the principal axes</strong>:</li>
</ol><pre><code># Visualize variable categorie contributions on axes 1
fviz_contrib(res.mca, choice =&quot;var&quot;, axes = 1)

# Visualize individual contributions on axes 1
# select the top 20
fviz_contrib(res.mca, choice =&quot;ind&quot;, axes = 1, top = 20)</code></pre>
<ol start="4"><li><strong>Graph of individuals</strong></li>
</ol><pre><code># Color by groups
# Add concentration ellipses
# Use repel = TRUE to avoid overplotting
grp </code></pre>
<div>
<p>
factoextra
</p>
</div>
<ol start="5"><li><strong>Graph of variable categories</strong>:</li>
</ol><pre><code>fviz_mca_var(res.mca, repel = TRUE)</code></pre>
<div>
<p>
factoextra
</p>
</div>
<ol start="6"><li><strong>Biplot of individuals and variables</strong>:</li>
</ol><pre><code>fviz_mca_biplot(res.mca, repel = TRUE)</code></pre>
<div>
<p>
factoextra
</p>
</div>
</div>
<div>
<h3>Advanced methods</h3>
<p>The factoextra R package has also functions that support the visualization of advanced methods such:</p>
<ul><li>Factor Analysis of Mixed Data (FAMD): : <a href="http://www.sthda.com/english/rpkgs/factoextra/reference/fviz_famd.html">FAMD Examples</a></li>
<li>Multiple Factor Analysis (MFA): <a href="http://www.sthda.com/english/rpkgs/factoextra/reference/fviz_mfa.html">MFA Examples</a></li>
<li>Hierarchical Multiple Factor Analysis (HMFA): <a href="http://www.sthda.com/english/rpkgs/factoextra/reference/fviz_hmfa.html">HMFA Examples</a></li>
<li><a href="http://www.sthda.com/hcpc-hierarchical-clustering-on-principal-components-hybrid-approach-2-2-unsupervised-machine-learning">Hierachical Clustering on Principal Components (HCPC)</a></li>
</ul></div>
</div>
<div>
<h2>Cluster analysis and factoextra</h2>
<p>To learn more about cluster analysis, you can refer to the book available at: <a href="http://www.sthda.com/english/wiki/practical-guide-to-cluster-analysis-in-r-book">Practical Guide to Cluster Analysis in R</a></p>
<p><a href="http://www.sthda.com/english/wiki/practical-guide-to-cluster-analysis-in-r-book"></a></p>
<p>The main parts of the book include:</p>
<ul><li>distance measures,</li>
<li>partitioning clustering,</li>
<li>hierarchical clustering,</li>
<li>cluster validation methods, as well as,</li>
<li>advanced clustering methods such as fuzzy clustering, density-based clustering and model-based clustering.</li>
</ul><p>The book presents the basic principles of these tasks and provide many examples in R. It offers solid guidance in data mining for students and researchers.</p>
<div>
<h3>Partitioning clustering</h3>
<p></p>
<pre><code># 1. Loading and preparing data
data(&quot;USArrests&quot;)
df </code></pre>
<div>
<p>
factoextra
</p>
</div>
<br><div>
<p>Read more:</p>
<ol><li><p><a href="http://www.sthda.com/cluster-analysis-in-r-unsupervised-machine-learning">Cluster analysis in R: All what you should know</a>.</p></li>
<li><a href="http://www.sthda.com/partitioning-cluster-analysis-quick-start-guide-unsupervised-machine-learning">Partitioning cluster analysis</a>.</li>
</ol></div>
<p><br></p>
</div>
<div>
<h3>Hierarchical clustering</h3>
<p></p>
<pre><code>library(&quot;factoextra&quot;)
# Compute hierarchical clustering and cut into 4 clusters
res </code></pre>
<div>
<p>
factoextra
</p>
</div>
<br><div>
<p>Read more:</p>
<ol><li><p><a href="http://www.sthda.com/cluster-analysis-in-r-unsupervised-machine-learning">Cluster analysis in R: All what you should know</a></p></li>
<li><a href="http://www.sthda.com/hierarchical-clustering-essentials-unsupervised-machine-learning">Hierarchical clustering essentials</a></li>
</ol></div>
<p><br></p>
</div>
<div>
<h3>Determine the optimal number of clusters</h3>
<pre><code># Optimal number of clusters for k-means
library(&quot;factoextra&quot;)
my_data </code></pre>
<div>
<p>
factoextra
</p>
</div>
</div>
</div>
<div>
<h2>Acknoweledgment</h2>
<p>I would like to thank <a href="https://github.com/inventionate">Fabian Mundt</a> for his active contributions to factoextra.</p>
<p>We sincerely thank all developers for their efforts behind the packages that <strong>factoextra</strong> depends on, namely, <a href="https://cran.r-project.org/package=ggplot2">ggplot2</a> (Hadley Wickham, Springer-Verlag New York, 2009), <a href="https://cran.r-project.org/package=FactoMineR">FactoMineR</a> (Sebastien Le et al., Journal of Statistical Software, 2008), <a href="https://cran.r-project.org/package=dendextend">dendextend</a> (Tal Galili, Bioinformatics, 2015), <a href="https://cran.r-project.org/package=dendextend">cluster</a> (Martin Maechler et al., 2016) and more …..</p>
</div>
<div>
<h2>References</h2>
<ul><li>H. Wickham (2009). ggplot2: Elegant Graphics for Data Analysis. Springer-Verlag New York.</li>
<li>Maechler, M., Rousseeuw, P., Struyf, A., Hubert, M., Hornik, K.(2016). cluster: Cluster Analysis Basics and Extensions. R package version 2.0.5.</li>
<li>Sebastien Le, Julie Josse, Francois Husson (2008). FactoMineR: An R Package for Multivariate Analysis. Journal of Statistical Software, 25(1), 1-18. 10.18637/jss.v025.i01</li>
<li>Tal Galili (2015). dendextend: an R package for visualizing, adjusting, and comparing trees of hierarchical clustering. Bioinformatics. DOI: 10.1093/bioinformatics/btv428</li>
</ul></div>
<div>
<h2>Infos</h2>
<p><span> This analysis has been performed using <strong>R software</strong> (ver. 3.3.2) and <strong>factoextra</strong> (ver. 1.0.4.999) </span></p>
</div>
</div>