【问题标题】:Supplementary variables in ggbiplot PCAggbiplot PCA 中的补充变量
【发布时间】:2016-06-01 11:02:20
【问题描述】:

我正在尝试使用 ggbiplot 绘制 PCA 结果,如何绘制补充变量? 我为 MCA 结果找到了 this discussion,但我也想要箭头...

 data(wine)
 wine.pca <- PCA(wine, scale. = TRUE, quanti.sup = c(4,5))
 plot(wine.pca)
 ggbiplot(wine.pca)

此外,这段代码给了我一个错误:

 1: In sweep(pcobj$ind$coord, 2, 1/(d * nobs.factor), FUN = "*") :
    STATS is longer than the extent of 'dim(x)[MARGIN]'
 2: In sweep(v, 2, d^var.scale, FUN = "*") :
    STATS is longer than the extent of 'dim(x)[MARGIN]' 

【问题讨论】:

    标签: r pca ggbiplot


    【解决方案1】:

    我尝试了您的代码,但没有重现您的错误,但遇到了其他问题。我搜索了PCA(),发现用于执行 PCA 的包是FactoMineR。查看文档后,我还将scale. 更改为scale.unit 并将quanti.sup 更改为quali.sup,给出了分类变量所在的正确列。

    library(FactoMineR)
    data(wine)
    wine.pca <- PCA(wine, scale.unit = TRUE, quali.sup = c(1,2))
    plot(wine.pca)
    ggbiplot(wine.pca)
    

    这应该会给出正确的输出。

    【讨论】:

      猜你喜欢
      • 2020-05-08
      • 1970-01-01
      • 1970-01-01
      • 2019-10-04
      • 1970-01-01
      • 2013-08-05
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多