我有一個小問題。我有三個資料框,列名彼此相同。我嘗試使用 lapply 為這三個資料幀運行三個不同的 PCA。然而它沒有用。我在這里附上了我的代碼。任何幫助表示贊賞。
library(factoextra)
library(FactoMineR)
mtcars
listA<-mtcars%>%
nest(-cyl)
listA$data # Here I created 3 list of dataframes based on cylinder capacity
lapply(listA$data,function(x[,1:6]) fviz_pca_biplot(PCA(x), label = "var", # Then tried to run separate PCA for each list; selecting column 1:6 in each dataframe
geom.ind="point",
pointsize=4,
alpha.ind = 0.8,
col.ind =x[[9]], # Here I tried to make color by 'gear type"
col.var = 'black',
select.var = list(contrib=30),
repel=TRUE,
mean.point=FALSE,
#habillage = as.factor(B$Class),
theme_classic()))
uj5u.com熱心網友回復:
我們需要指定引數名,即ggtheme對theme_classic()
out <- lapply(listA$data,function(x) fviz_pca_biplot(PCA(x[, 1:6]), label = "var", # Then tried to run separate PCA for each list; selecting column 1:6 in each dataframe
geom.ind="point",
pointsize=4,
alpha.ind = 0.8,
col.ind = x[[9]], # Here I tried to make color by 'gear type"
col.var = 'black',
select.var = list(contrib=30),
repel=TRUE,
mean.point=FALSE,
habillage = as.factor(x[[9]]),
ggtheme = theme_classic()))
轉載請註明出處,本文鏈接:https://www.uj5u.com/net/373000.html
