README.md

FactoHelpeR

Build
status Build
Status codecov

Project Status: Suspended – Initial development has started, but
there has not yet been a stable, usable release; work has been stopped
for the time being but the author(s) intend on resuming
work. lifecycle

Overview

Extract and visualize FactoMineR results. This package provides several methods for plotting and summarizing results of multivariate exploratory data analysis (e.g. PCA, CA). FactoHelpeR uses ggplot2, this makes it easy to customize plots (e.g. using themes, stat and scales).

This package only supports Principal Component Analysis (PCA) and Correspondence Analysis (CA).

Installation

You can install the development version from GitHub with:

# install.packages("devtools")
devtools::install_github("nfrerebeau/FactoHelpeR")

Usage

FactoHelpeR provides a set of S3 methods to explore the results of multivariate data analysis from FactoMineR:

library(FactoHelpeR)
library(FactoMineR)

# PCA
data(decathlon)
results <- FactoMineR::PCA(decathlon, scale.unit = TRUE, quanti.sup = 11:12,
                           quali.sup = 13, graph = FALSE)
# Extract individuals coordinates
ind_coord <- extract(results, "ind coord")
head(ind_coord)
#>              Dim.1      Dim.2      Dim.3      Dim.4      Dim.5
#> SEBRLE   0.7916277  0.7716112  0.8268412  1.1746274  0.7071590
#> CLAY     1.2349906  0.5745781  2.1412470 -0.3548448 -1.9745714
#> KARPOV   1.3582149  0.4840209  1.9562580 -1.8565241  0.7952147
#> BERNARD -0.6095151 -0.8746285  0.8899407  2.2206124  0.3616362
#> YURKOV  -0.5859683  2.1309542 -1.2251568  0.8735791  1.2513692
#> WARNERS  0.3568895 -1.6849567  0.7665531 -0.5893047  1.0016616
# Summarize results for the first 5 active variables along the first component
(ind <- summarize(results, "var", rows = 1:5, axes = 1))
#>            PC1.coord  PC1.cos2 PC1.contrib
#> 100m      -0.7747198 0.6001908   18.343770
#> Long.jump  0.7418997 0.5504152   16.822467
#> Shot.put   0.6225026 0.3875094   11.843540
#> High.jump  0.5719453 0.3271214    9.997887
#> 400m      -0.6796099 0.4618697   14.116229
# Plot individuals
visualize(results, map = "ind", axes = c(1, 2), group = 13) +
  ggplot2::labs(title = "Individuals map") +
  ggplot2::theme_bw()

# Plot variables and supplementary categories
visualize(results, map = "variables", axes = c(1, 2),
          extra = c("quanti", "quali")) +
  ggrepel::geom_label_repel(size = 3, segment.colour = "grey", seed = 123) +
  ggplot2::labs(title = "Variables map") +
  ggplot2::theme_bw()

# Plot eigenvalues and cumulative percentage of variance
visualize(results, map = "eig") +
  ggplot2::theme_bw()



nfrerebeau/FactoHelpeR documentation built on Nov. 5, 2019, 3:16 p.m.