我想获取/绘制每种葡萄酒类别(巴罗洛、格里诺利诺、巴贝拉)的特征的贡献。使用fviz_contrib我得到了所有类的贡献,如下面的 MWE 所示。但是我想知道是否以及如何计算/绘制按类/组单独过滤的它们。
library(ggbiplot)
library(factoextra)
data(wine)
wine.pca <- prcomp(wine, scale. = TRUE)
# plot the PCA
print(ggbiplot(wine.pca, obs.scale = 1, var.scale = 1, groups = wine.class, ellipse = TRUE, circle = TRUE))
# plot the contributions of the features for all wine classes
g.contr <- fviz_contrib(wine.pca, choice = "var", axes = 1:2, fill = "lightblue", color = "darkblue", top = 45)
print(g.contr)