Hi, I am starting to use this program and I am just beginning to familiarize myself with this language.
My problem is that I have a data matrix with 12 columns, that is, 12 variables and I need to make a PCA graph where each variable has a different color.
With the help of a tutorial I wrote the following code:
datos= Nogal_sequia_pca
attach(Nogal_sequia_pca)
summary(datos)
myPr <- prcomp(datos[1:12], scale = TRUE)
myPr
summary(myPr)
plot(myPr, type = "l")
biplot(myPr, scale = 0)
str(myPr)
myPr$x
datos2 <- cbind(datos, myPr$x[, 1:2])
head(datos2)
install.packages("ggplot2")
library(ggplot2)
Then, the rest of the tutorial does not help me since the graph separates by color according to another column with categorical variables.
I enclose an image with the data matrix. Beforehand thank you very much!