inst/examples/ex-visualize.R

library(FactoMineR)

# PCA
data(decathlon)
res_pca <- FactoMineR::PCA(decathlon, scale.unit = TRUE, quanti.sup = 11:12,
                           quali.sup = 13, graph = FALSE)
## Plot the 10 first individuals
visualize(res_pca, map = "ind", select = 1:10) +
  ggrepel::geom_label_repel() +
  ggplot2::theme_bw()
## Plot individuals and draw ellipses
visualize(res_pca, map = "ind", group = 13) +
  ggplot2::stat_ellipse()
## Plot the first 5 variables with highest contributions
visualize(res_pca, map = "variables", select = "contrib 5") +
  ggrepel::geom_label_repel()
## Plot supplementary variables
visualize(res_pca, map = "variables", extra = c("quanti", "quali")) +
  ggrepel::geom_label_repel()
## Plot eigenvalues
visualize(res_pca, map = "eig") +
  ggplot2::theme_bw()

# CA
data(children)
res_ca <- FactoMineR::CA(children, col.sup = 6:8, row.sup = 15:18,
                         graph = FALSE)
## Plot CA map with supplementary rows and columns
visualize(res_ca, extra = c("rows", "columns")) +
  ggrepel::geom_label_repel() +
  ggplot2::theme_bw()
## Plot the 10 first rows
visualize(res_ca, map = "rows", select = 1:10) +
  ggrepel::geom_label_repel() +
  ggplot2::theme_bw()
## Plot only the first 5 variables with highest contributions
visualize(res_ca, map = "columns", select = "coord 5") +
  ggrepel::geom_label_repel()
nfrerebeau/FactoHelpeR documentation built on Nov. 5, 2019, 3:16 p.m.