Open file and set up initial MFA with “groups”

library(tidyverse)
## -- Attaching packages -------------------------------------------------- tidyverse 1.3.0 --
## v ggplot2 3.3.0     v purrr   0.3.4
## v tibble  3.0.1     v dplyr   0.8.5
## v tidyr   1.0.3     v stringr 1.4.0
## v readr   1.3.1     v forcats 0.5.0
## -- Conflicts ----------------------------------------------------- tidyverse_conflicts() --
## x dplyr::filter() masks stats::filter()
## x dplyr::lag()    masks stats::lag()
library(FactoMineR)
library(factoextra)
## Welcome! Want to learn more? See two factoextra-related books at https://goo.gl/ve3WBa
setwd("C:/Users/19419/OneDrive - Washington State University (email.wsu.edu)/WSU/SMOKE/Stone Tree Bin Trials") 
# read in the data
smkDA <- read.csv("bucket sensory gc wine collab.csv", header = TRUE)
smkDA2 <- column_to_rownames(smkDA,var="Sample")
res.MFA <- MFA(smkDA2,
               group = c(2,5,6,11,7,3),
               type = c("n","s","s","s","s","s"),
               name.group = c("origin","basic chemistry","phenolics","odor intensity",                               "taste","smoke taint"),
               num.group.sup = 1,
               graph = FALSE)

groups of variable

group <- get_mfa_var(res.MFA, "group")
group
## Multiple Factor Analysis results for variable groups 
##  ===================================================
##   Name           Description                                          
## 1 "$coord"       "Coordinates"                                        
## 2 "$cos2"        "Cos2, quality of representation"                    
## 3 "$contrib"     "Contributions"                                      
## 4 "$correlation" "Correlation between groups and principal dimensions"
fviz_mfa_var(res.MFA, "group")

fviz_contrib(res.MFA, "group", axes = 1)

fviz_contrib(res.MFA, "group", axes = 2)

Quantitative Variables

quanti.var <- get_mfa_var(res.MFA, "quanti.var")
quanti.var
## Multiple Factor Analysis results for quantitative variables 
##  ===================================================
##   Name       Description                      
## 1 "$coord"   "Coordinates"                    
## 2 "$cos2"    "Cos2, quality of representation"
## 3 "$contrib" "Contributions"
fviz_mfa_var(res.MFA, "quanti.var", palette = "jco", 
             col.var.sup = "violet", repel = TRUE,
             geom = c("point", "text"), legend = "bottom")

fviz_contrib(res.MFA, choice = "quanti.var", axes = 1, top = 20,
             palette = "jco")

fviz_contrib(res.MFA, choice = "quanti.var", axes = 2, top = 20,
             palette = "jco")

fviz_mfa_var(res.MFA, "quanti.var", col.var = "contrib", 
             gradient.cols = c("#00AFBB", "#E7B800", "#FC4E07"), 
             col.var.sup = "violet", repel = TRUE,
             geom = c("point", "text"))

Graph of Individuals

ind <- get_mfa_ind(res.MFA)
ind
## Multiple Factor Analysis results for individuals 
##  ===================================================
##   Name                      Description                      
## 1 "$coord"                  "Coordinates"                    
## 2 "$cos2"                   "Cos2, quality of representation"
## 3 "$contrib"                "Contributions"                  
## 4 "$coord.partiel"          "Partial coordinates"            
## 5 "$within.inertia"         "Within inertia"                 
## 6 "$within.partial.inertia" "Within partial inertia"
fviz_mfa_ind(res.MFA, 
             habillage = "Varietal",
             palette = c("#00AFBB", "#E7B800", "#FC4E07","green"),
             repel = TRUE,
             label = FALSE)

fviz_mfa_ind(res.MFA,
             habillage = "Varietal", # color by groups 
             palette = c("#00AFBB", "#E7B800", "#FC4E07","green"),
             addEllipses = TRUE, ellipse.type = "confidence", 
             repel = TRUE # Avoid text overlapping
             ) 

fviz_ellipses(res.MFA, c("Varietal", "Block"), repel = TRUE)

Graph of Partial Axes

fviz_mfa_axes(res.MFA, repel = TRUE)