2.2 Data: Sensory Profiles of Sausages

Overview:

Data: Sensory Profiles of Sausages Rows: 64 obs, 8 types of sausages Columns: 19 attributes + Session (Sausage Type) Panel: 9 Panelists in total but we had to eliminate 3 Panelists (JUAN, Mine, Raul) that did not rate all products (this is to satisfy the balance-between-groups condition in MFA). Note: Ratings on 10-point scale

Load necessary packages:

library(readxl)                  #to read data the excel files 
library(ggplot2)                 #to plot really pretty graphs
library(corrplot)                #to assess correlation and make correlation plots 
library(PerformanceAnalytics)    #another cool package to look at correlation
library(PTCA4CATA)               #amazing package from Dr. Abdi to do support works 4 analysis
library(data4PCCAR)              #amazing package no.2 from Dr. Abdi to do PCA & CA
library(ExPosition)              #package for PCA calculations
library(InPosition)              #another package for PCA calculation that also include inference (BR, CI)
library(graphics)                #default on in R. Just making sure. For fine-tunings
library(dplyr)                   #for data manipulations
library(tidyverse)               #collection of vital packages 
library(data.table)              #for data manipulation
library(knitr)                   #to make nice Rmarkdown including neat html tables
library(kableExtra)              #make scrollable tables
library(gridExtra)
require(ggplotify)              #these 2 helps combine plots
#install.packages("devtools")
#devtools::install_github('HerveAbdi/data4PCCAR')
#devtools::install_github('HerveAbdi/PTCA4CATA')

Load data:

#use readxl to read from excel files
sausage.raw <- read_excel("Sausage Data.xlsx") #don't hard code location, 
                                               #just direct to data file by name as long as it is in the same folder
a <- kable(sausage.raw)                        #taking a peak at our data
scroll_box(a, width = "100%", height = "300px")
Panelist Product Session Aroma impact Flavor impact Salty Umami Acidic Bitter Alliaceous Animalic savory Bloody Floury Dark meat Eggy Fatty HVP Juicy savory Rubbery Smokey Spicy White meat
XEL Salchicha de Pavo Nutrideli 1 4.0 6.0 3.0 4.0 1.0 0.0 2.5 2.0 5.0 1.5 3.0 1.0 2.1 2.0 4.0 4.0 3.0 3.0 5.0
LALO Salchicha de Pavo Nutrideli 1 5.0 8.0 2.5 4.0 2.0 0.0 3.0 1.0 2.0 3.0 2.2 3.0 4.0 2.0 4.0 4.0 4.5 2.0 5.0
JUAN Salchicha de Pavo Nutrideli 1 3.0 6.0 3.5 2.0 2.0 0.0 2.5 3.0 0.0 3.0 2.5 0.5 4.0 2.0 2.0 3.0 1.0 3.0 5.0
MARTHA Salchicha de Pavo Nutrideli 1 5.0 5.5 4.0 5.0 2.0 0.0 4.0 2.0 3.0 2.0 5.2 2.0 5.1 2.0 6.0 5.0 4.0 3.0 3.0
NERI Salchicha de Pavo Nutrideli 1 6.0 6.0 2.5 2.0 1.5 0.0 2.0 1.0 1.5 3.0 4.0 0.0 4.0 4.5 3.0 5.2 2.0 2.0 5.0
DIANA Salchicha de Pavo Nutrideli 1 6.0 7.0 5.5 4.5 2.5 0.0 3.5 5.0 2.0 4.0 4.0 2.0 5.1 2.0 2.5 3.0 3.5 7.0 6.0
DULCE Salchicha de Pavo Nutrideli 1 4.0 6.0 3.0 4.0 1.0 0.0 4.0 3.0 2.0 4.5 4.0 2.0 2.1 6.0 3.5 3.0 4.0 3.0 5.0
RAUL Salchicha de Pavo Nutrideli 1 3.0 9.0 5.0 1.0 2.0 0.0 3.0 4.0 3.0 1.5 3.5 3.0 2.1 3.0 4.0 2.2 2.0 3.0 6.0
XEL Salchicha de pavo FUD 1 3.0 5.0 3.0 2.0 2.0 3.0 2.0 2.0 3.9 2.0 2.0 3.0 2.0 2.0 1.0 4.0 4.0 3.0 5.0
LALO Salchicha de pavo FUD 1 4.5 8.0 3.0 3.0 2.0 5.0 2.0 1.5 0.9 4.0 2.0 1.0 3.0 2.5 3.0 3.5 2.0 2.0 5.0
MINE Salchicha de pavo FUD 1 5.0 6.0 2.0 2.5 1.0 2.0 3.0 2.0 2.0 3.0 2.0 2.0 4.0 3.0 2.0 2.4 3.0 3.0 4.0
MARTHA Salchicha de pavo FUD 1 5.0 6.0 3.0 2.0 1.0 4.0 2.0 1.0 0.9 3.5 2.0 0.0 4.0 2.0 5.0 3.0 0.0 3.0 3.0
NERI Salchicha de pavo FUD 1 6.0 6.0 3.0 4.0 2.5 3.5 4.0 2.0 1.5 4.0 4.0 1.0 2.0 4.0 3.0 4.0 2.0 2.5 6.0
DIANA Salchicha de pavo FUD 1 4.0 5.0 3.0 2.0 4.0 3.0 3.0 4.5 3.0 3.0 2.5 3.5 5.0 2.0 3.5 2.4 2.0 3.5 5.0
DULCE Salchicha de pavo FUD 1 3.0 6.0 5.0 5.0 2.0 2.0 3.5 1.0 3.9 4.0 2.0 4.0 3.0 3.0 2.0 4.0 2.0 3.0 5.0
RAUL Salchicha de pavo FUD 1 3.0 5.0 2.0 2.0 4.0 4.0 2.5 3.0 2.0 2.0 6.0 2.0 5.0 0.0 1.0 5.4 3.5 5.0 3.0
XEL Salchicha pavo CHERO 1 4.0 5.3 3.0 3.0 2.0 3.0 3.0 2.0 2.0 5.0 3.0 1.0 3.0 3.0 2.0 0.0 2.0 3.0 2.0
LALO Salchicha pavo CHERO 1 5.0 5.5 3.0 2.0 3.0 1.5 2.0 4.0 1.5 4.5 3.0 1.5 2.0 1.5 2.0 0.0 3.0 2.0 1.2
JUAN Salchicha pavo CHERO 1 4.0 8.3 3.0 2.0 2.0 0.0 2.0 4.0 1.0 4.0 5.0 3.0 3.0 3.0 4.0 0.0 3.0 2.0 3.0
MARTHA Salchicha pavo CHERO 1 6.0 5.0 4.0 3.0 1.0 0.5 3.0 4.0 0.0 4.0 3.0 0.0 3.0 2.0 0.5 0.0 2.0 3.0 1.2
NERI Salchicha pavo CHERO 1 6.0 6.0 3.0 2.0 4.0 1.0 2.5 2.5 2.0 5.0 4.0 1.5 2.0 2.0 3.0 0.0 1.5 1.0 4.2
DIANA Salchicha pavo CHERO 1 7.5 8.0 5.0 3.0 4.0 1.5 3.0 4.5 0.0 7.0 4.0 0.0 3.0 4.0 5.0 0.0 4.5 2.0 4.2
DULCE Salchicha pavo CHERO 1 5.0 7.0 4.0 3.0 2.0 0.0 3.0 2.0 2.0 6.0 4.0 2.0 3.0 3.0 3.0 0.0 4.0 3.0 1.2
RAUL Salchicha pavo CHERO 1 4.0 7.0 3.0 0.0 4.0 2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2.0 2.0 4.0 4.0 3.0 4.0 4.0 0.0 2.0
JUAN Salchicha Viena Nutrideli 2 4.0 8.0 3.0 1.5 0.0 0.0 2.0 4.0 1.5 0.0 4.0 2.0 3.0 0.0 5.0 2.0 3.0 0.0 3.0
MARTHA Salchicha Viena Nutrideli 2 3.0 8.0 2.0 5.0 0.0 0.0 3.5 1.0 0.0 0.0 4.0 1.0 4.0 1.0 3.0 2.0 1.0 0.0 1.8
NERI Salchicha Viena Nutrideli 2 3.0 5.0 3.0 4.0 0.0 0.0 2.0 2.0 2.5 0.0 4.0 3.0 2.5 2.0 3.0 2.0 3.0 0.0 4.8
DIANA Salchicha Viena Nutrideli 2 5.0 5.0 5.0 3.0 0.0 0.0 3.0 3.0 2.0 0.0 6.0 1.0 4.5 2.0 3.0 2.0 3.5 0.0 4.0
DULCE Salchicha Viena Nutrideli 2 6.0 6.0 2.0 1.0 0.0 0.0 2.0 4.5 1.0 0.0 5.5 0.5 3.0 2.0 4.0 3.0 2.0 0.0 4.0
RAUL Salchicha Viena Nutrideli 2 4.0 6.0 3.0 3.0 0.0 0.0 3.0 0.0 3.0 0.0 4.0 1.0 5.0 3.0 4.0 5.0 3.0 0.0 3.0
XEL Salchicha viena FUD 2 4.0 5.0 3.0 4.0 1.0 0.0 4.0 2.0 2.0 0.0 5.0 2.0 3.0 0.0 3.0 0.0 3.0 0.0 0.0
LALO Salchicha viena FUD 2 4.0 6.0 4.0 3.5 2.0 0.0 3.0 2.0 2.0 0.0 5.0 3.0 3.5 0.0 3.0 0.0 3.5 0.0 3.0
JUAN Salchicha viena FUD 2 5.0 8.0 2.0 3.0 1.5 0.0 3.0 2.5 2.0 0.0 5.0 3.5 3.0 0.0 5.0 0.0 3.0 0.0 2.0
MARTHA Salchicha viena FUD 2 4.0 6.0 2.0 5.0 1.0 0.0 3.0 4.0 1.0 0.0 3.0 0.0 3.0 0.0 4.0 0.0 3.0 0.0 2.0
NERI Salchicha viena FUD 2 7.0 8.0 2.5 2.0 2.5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2 3.0 6.0 4.0 2.0 1.0 0.0 3.0 0.7 4.0 5.0 5.0 0.0 4.0 3.0 2.0 6.0 2.0 3.0 3.0
XEL SALCHICHA VIENA CHIMEX 2 5.0 5.0 3.0 4.0 1.0 0.0 3.0 2.0 3.0 3.0 0.0 2.0 2.0 3.0 3.0 2.0 3.0 3.0 5.0
LALO SALCHICHA VIENA CHIMEX 2 4.5 6.0 3.5 4.0 2.0 0.0 2.5 2.0 2.0 3.0 0.0 2.0 3.0 2.5 3.0 3.5 3.0 3.5 5.0
JUAN SALCHICHA VIENA CHIMEX 2 5.5 8.0 4.0 3.0 1.0 0.0 3.0 0.5 1.0 2.0 0.0 2.0 2.0 1.0 2.0 3.0 4.0 1.0 3.0
MINE SALCHICHA VIENA CHIMEX 2 5.0 9.0 2.0 3.0 1.5 0.0 3.0 3.5 0.0 3.0 0.0 3.0 2.0 2.0 4.0 2.0 2.0 4.0 5.0
MARTHA SALCHICHA VIENA CHIMEX 2 7.0 6.0 4.0 4.0 2.0 0.0 4.0 2.0 0.0 3.0 0.0 0.0 2.0 1.0 3.0 4.0 3.0 2.0 4.0
NERI SALCHICHA VIENA CHIMEX 2 6.0 7.0 3.0 4.0 2.5 0.0 3.0 2.0 1.0 2.0 0.0 0.0 3.0 1.5 3.5 4.0 2.5 2.0 3.0
DIANA SALCHICHA VIENA CHIMEX 2 7.0 7.0 5.0 4.0 3.0 0.0 3.5 4.0 0.0 6.0 0.0 2.0 3.5 3.0 4.0 4.0 2.5 2.0 7.0
DULCE SALCHICHA VIENA CHIMEX 2 7.0 6.0 2.0 2.0 1.0 0.0 4.0 3.0 3.0 4.0 0.0 1.0 3.0 0.0 3.0 3.0 3.5 2.0 4.0

Convert to data.frame and show snippet of data

#we will use wks to name and keep track of all version of data
wk0 <- as.data.frame(sausage.raw)

Data processing:

Goal is to make as many variations of data as needed. I prefer to work with data frame as it is easy to manipulate.Here I made 2 assumptions: 1. panelist ratings are independent of each others 2. session 1 and 2 are independent and has similar testing conditions.

#take out panelist names and product names
wk1 <- wk0[, -1]

#take out product names
wk2 <- wk1[, -1]

#take out sessions
wk3 <- wk2[,-1]

#make sure data is all numeric now
#summary(wk3)

#take out panelist, products and sessions
wk4 <- wk1[,-2]

Find means by product names and finalize:

#covert wk4 back to data tables to find means with dyplyr
wk4.as.dt <- as.data.table(wk4)
wk5 <- wk4 %>% 
  group_by(Product) %>%
  summarise_all("mean")

#Finalize and add product names as row names
wk6 <- as.data.frame(wk5) 
sausage.processed.mean <- as.data.frame(wk6[,-1])
rownames(sausage.processed.mean) <- wk6$Product

#just numeric values (we will use this)
sausage.processed <-  wk0[, -c(1:3) ]

#just taking a quick look - should be ready to go
#sausage.processed

Correlation Plot:

#correlation plot 3: mixed circle visualization (top) and numbers (bottom) 
cor.temp <- cor(sausage.processed)
corrplot3 <- corrplot.mixed(cor(sausage.processed), upper = 'circle', 
                            lower = "number",
                            tl.pos = "lt", 
                            tl.col = "black",
                            tl.cex = 0.8,
                            addCoefasPercent = TRUE,
                            number.cex=0.8)

#corrplot3
corrplot3 <- recordPlot()

Note:

From correlation plot, we can see that the variables have both positive and negative relationships. While most of these relationships make sense in the real-world, we always have to keep in mind that all of our assumptions to only hold true in the context of the dataset.