How to plot a PCA table
I'm studying PCA method with the package PCAmixdata
because I have a dataset with numerical and categorical variable. This is my example code in R:
library(dplyr)
library(PCAmixdata)
data - starwars
db_quali - as.data.frame(starwars[,4:6])
db_quanti - as.data.frame(starwars[,2:3])
pca_table - PCAmix(X.quanti = db_quanti,
X.quali = db_quali,
rename.level=TRUE,
graph = TRUE)
Gender - factor(data$gender)
par(xpd=TRUE,mar=rep(8,4))
plot(pca_table ,choice=ind,label=FALSE,
posleg=xy.coords(2,-10), main=Observations, coloring.ind = Gender)
I know that the function ggplot
can be used only with data.frame
and at the moment I have a list
. Is there a way to convert pca_table
into a data.frame
to use the function ggplot
?
I want to do this because in my original dataset I have many classes and with the function plot I have a limited set of colors, so a color could correspond to more than one class.
Topic pcamixdata pca ggplot2 r
Category Data Science