Skip to contents

ggfacto draws readable, interactive graphs of the principal component, correspondence and multiple correspondence analyses of FactoMineR. Its point is less visual than statistical: hover over a point, and the graph shows the crosstables behind it, each deviation from the mean coloured, so that the geometry is always read against the data it summarises. The graphs are ggplot objects, to be extended with +.

ggfacto is, for the most part, a wrapper around FactoMineR, which computes the analyses — our thanks to its authors, François Husson, Julie Josse, Sébastien Lê and Jérémy Mazet. Its clustering reproduces FactoMineR::HCPC(), and its tables are built with tabxplor.

Installation

install.packages("ggfacto")

A multiple correspondence analysis

tea, a survey shipped with FactoMineR, asked 300 people 18 questions about how they drink tea. The analysis, then the interpretation of its first two axes, the eigenvalues underneath:

data(tea, package = "FactoMineR")

mca <- multiple_correspondence_analysis(tea, 1:18)
interpret(mca, axes = 1:2)
Question contrib Positive_levels Negative_levels
<col%> <col%> <col%>
Axe 1: 9.9% of variance (mod. 55%) where 15.7% chain store+tea shop 11.3% chain store 4.4%
tearoom 13.9% tearoom 11.2% Not.tearoom 2.7%
how 11.2% tea bag+unpackaged 6.8% tea bag 4.3%
friends 9.1% friends 3.2% Not.friends 6.0%
resto 8.5% resto 6.3% Not.resto 2.2%
price 8.1% p_variable 3.5% p_branded 3.0%
tea.time 7.2% tea time 3.1% Not.tea time 4.1%
pub 5.5% pub 4.4%
work 4.2% work 3.0%
How 3.9% other 2.3%
Tea 3.4% green 3.0%
lunch 2.8% lunch 2.4%
Above mean ctr 87.0% 57.3% 29.6%
Axe 2: 8.1%
of variance
(mod. 28%)
where 28.6% tea shop 23.9% chain store 4.6%
price 25.6% p_upscale 20.5% p_branded 2.5%
how 23.4% unpackaged 18.9% tea bag 4.5%
Tea 7.3% green 3.3% Earl Grey 2.4%
Above mean ctr 80.5% 66.6% 13.9%

Contribution to the variance of the axis: a level on the positive side, contributing ×1; ×2; ×5; ×10 the mean contribution; a level on the negative side, contributing ×1; ×2; ×5; ×10 the mean contribution.
contrib: the whole question’s contribution to the axis

Axe eigenvalue % variance cumul. Benzecri’s
modified rate
cumul. mod.
<var> <col%> <col%>
Axe 1 0.148 9.9% 9.9% 55.4% 55.4%
Axe 2 0.122 8.1% 18.0% 28.1% 83.4%
Axe 3 0.090 6.0% 24.0% 7.6% 91.1%
Axe 4 0.078 5.2% 29.2% 3.3% 94.3%
Axe 5 0.074 4.9% 34.1% 2.1% 96.5%
Axe 6 0.071 4.8% 38.9% 1.6% 98.1%
Axe 7 0.068 4.5% 43.4% 1.0% 99.1%
Axe 8 0.065 4.4% 47.7% 0.6% 99.7%
… of 27
Total 1.500 100% 100%

The clusters, added to the data frame, then the interactive graph. Hover over a category to see its crosstables with the other questions, and over a grey point to see a response pattern:

tea <- tea |> dplyr::mutate(clusters = hierarchical_clust(mca, ncp = 3))

ggfacto(mca, tea, clust = clusters, interactive = TRUE)

Learn more

The guide (en français) walks through the three analyses, their tables and graphs, and clustering.