簡體   English   中英

ggplot錯誤:“名稱”屬性[2]的長度必須與向量[1]相同

[英]ggplot error: 'names' attribute [2] must be the same length as the vector [1]

我想使用PCA,但無法繪制! 我使用packege和以下代碼成功運行了PCA:

  pc<-prcomp(C, scale = FALSE)
  summary(pc) 

然后我用的情節

   library(devtools)
   install_github("vqv/ggbiplot")
   library(ggbiplot)
   ggbiplot(pc)

但是我得到這個錯誤:

   Error in names(df.v) <- names(df.u) : 
   'names' attribute [2] must be the same length as the vector [1]

我通常使用ggplot滿足我的PCA繪圖需求,因為它允許我通過顏色/形狀編碼覆蓋元數據。

基本PCA的典型代碼如下:

    library(ggfortify)
    library(ggrepel)
    library(GGally)
    library(gplots)
    library(ggplot2)
    x <- prcomp(y)
    autoplot(x) + #any color/shape/text edits you want to make

這段代碼是由與我一起工作的人傳給我的,但是我沒有任何問題。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM