| axis_coord | R Documentation |
The coordinates of each individual on the axes of a principal component analysis or of a
multiple correspondence analysis, to write into the data frame with dplyr::mutate(), like
hierarchical_clust:
'data <- data |> mutate(axe1 = axis_coord(res, 1))'
An analysis made with multiple_correspondence_analysis is computed on the distinct
answer profiles, so its '$ind$coord' has one row per profile: 'axis_coord()' gives each
individual the coordinate of its profile. In a correspondence analysis, each individual takes the
coordinate of its level.
axis_coord(res, axes = 1, margin = "rows")
res |
An analysis made with |
axes |
The axes. Several axes give a data frame, which |
margin |
For a correspondence analysis, the variable whose levels give the coordinates: '"rows"', the default, or '"columns"'. |
One value per row of the data frame: inside dplyr::mutate(), of the data frame
being written, with 'NA' on the rows the analysis did not use (when it was made on a subset of
the population); outside, of the data frame the analysis started from. For a correspondence
analysis outside mutate(), one value per level, named after it.
data(tea, package = "FactoMineR")
res.mca <- multiple_correspondence_analysis(tea, 1:18)
tea <- tea |>
dplyr::mutate(axe1 = axis_coord(res.mca, 1),
axis_coord(res.mca, c(axe2 = 2, axe3 = 3)))
# How much of the first axis does age explain?
summary(stats::lm(axe1 ~ age_Q, data = tea))$r.squared
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.