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

loop for Principal Component Analysis does not work

$
0
0

I have two dataframes

df1 <- data.frame(item1 = c("5", "8", "2"), item2 = c("2", "2", "6"), item3 = c("4", "78", "76"))

df2 <- data.frame(item1 = c("54", "82", "12"), item2 = c("6", "7", "87"), item3 = c("3", "8", "7"))

I want to perform a PCA in a loop like this

list <- as.list(c(df1,df2))
for(item in list){
  pca <- PCA(item)
pca_individuel <- fviz_pca_ind(pca, pointsize = "cos2", 
             pointshape = 21, fill = "cos2",
             repel = TRUE, # Avoid text overlapping (slow if many points)
             geom = "point", # no text only points
             title = "PCA of food"
             )
View(pca_individuel) }

It shows this error:

Error in facto_summarize(X, element = element, axes = axes, result = summary.res) : The value of the argument axes is incorrect. The number of axes in the data is: 1. Please try again with axes between 1 - 1

Who can spot my mistake? I appreciate every trial.

I thank you in advance IT-girl


Viewing all articles
Browse latest Browse all 211983

Trending Articles



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