Quantcast
Channel: Active questions tagged r - Stack Overflow
Viewing all articles
Browse latest Browse all 206571

How can I perform a PCA with variables of three different data frames and color discriminate them?

$
0
0

I have three data frames and I want to perform a Principal Component Analysis (PCA) in R. I merged the data frames with rbind() and did a PCA with that. That worked. But I want to discriminate the dots according to the data frame they belong to. With the merged data frame, that is impossible (or isn´t it?). When I use PCA(X=c(df1,df2,df3) it is complaining about differing number of rows (which is obviously actually the case).

pca <- PCA(X=c(df1,df2,df3))
fviz_pca_ind(pca,
             geom.ind = "point", # show points only (nbut not "text")
             col.ind = c(df1,df2,df3), # color by groups
             palette = c("#00AFBB", "#E7B800", "#FC4E07"),
             addEllipses = TRUE, # Concentration ellipses
             legend.title = "Groups"
             )

That is not working...

How can I perform a PCA with variables of three different data frames and color discriminate them? I have no reprex because it is difficult to provide in that case.

Thank you all for your suggestions ;)


Viewing all articles
Browse latest Browse all 206571

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>