It is important to know the correlation between the constituents of a product (in this case the fish meal), so we merge the "dry matter", "protein", "fat" and "ash" into a Y matrix and calculate the correlation.
y<-as.matrix(cbind(fish1$DM,fish1$PROTEIN,
fish1$FAT,fish1$ASH))
Now let´s give a name to the columns of the matrix:
colnames(y)<-c("DM","PROTEIN","FAT","ASH")
The best way to check the correlation is in a matrix form so let´s load the package "coorplot":
library(corrplot)
corrplot(cor_y,method="number")
and we get this plot:
We can see that there is a high negative correlation between "ash" and "fat", and a very low (almost cero) correlation between "protein" and "dry matter".
Let´s check this in a XY plot:
library(ggpubr)
ggscatter(fish1_df, x = "fat", y = "ash",
add = "reg.line", conf.int = TRUE,
cor.coef = TRUE, cor.method = "pearson",
xlab = "FAT", ylab = "ASH")
ggscatter(fish1_df, x = "protein", y = "dm",
add = "reg.line", conf.int = TRUE,
cor.coef = TRUE, cor.method = "pearson",
xlab = "PROTEIN", ylab = "DRY MATTER")
To know this correlations it is important to interpret better the loadings, regression coefficients ,...
No hay comentarios:
Publicar un comentario