我正在學習使用wine
數據集的雙標圖。 R如何知道Barolo,Grignolino和Barbera是wine.class
,而我們在數據集中沒有看到葡萄酒類專欄?組中的ggbiplot圖形顯示
有關wine
數據集的更多細節在以下鏈接
ggbiplot - how not to use the feature vectors in the plot
https://github.com/vqv/ggbiplot
非常感謝
我正在學習使用wine
數據集的雙標圖。 R如何知道Barolo,Grignolino和Barbera是wine.class
,而我們在數據集中沒有看到葡萄酒類專欄?組中的ggbiplot圖形顯示
有關wine
數據集的更多細節在以下鏈接
ggbiplot - how not to use the feature vectors in the plot
https://github.com/vqv/ggbiplot
非常感謝
在wine
數據集,你有兩個對象,一個data.frame
wine
有178個觀察值有13個定量變量:
str(wine)
'data.frame': 178 obs. of 13 variables:
$ Alcohol : num 14.2 13.2 13.2 14.4 13.2 ...
$ MalicAcid : num 1.71 1.78 2.36 1.95 2.59 1.76 1.87 2.15 1.64 1.35 ...
$ Ash : num 2.43 2.14 2.67 2.5 2.87 2.45 2.45 2.61 2.17 2.27 ...
$ AlcAsh : num 15.6 11.2 18.6 16.8 21 15.2 14.6 17.6 14 16 ...
$ Mg : int 127 100 101 113 118 112 96 121 97 98 ...
$ Phenols : num 2.8 2.65 2.8 3.85 2.8 3.27 2.5 2.6 2.8 2.98 ...
$ Flav : num 3.06 2.76 3.24 3.49 2.69 3.39 2.52 2.51 2.98 3.15 ...
$ NonFlavPhenols: num 0.28 0.26 0.3 0.24 0.39 0.34 0.3 0.31 0.29 0.22 ...
$ Proa : num 2.29 1.28 2.81 2.18 1.82 1.97 1.98 1.25 1.98 1.85 ...
$ Color : num 5.64 4.38 5.68 7.8 4.32 6.75 5.25 5.05 5.2 7.22 ...
$ Hue : num 1.04 1.05 1.03 0.86 1.04 1.05 1.02 1.06 1.08 1.01 ...
$ OD : num 3.92 3.4 3.17 3.45 2.93 2.85 3.58 3.58 2.85 3.55 ...
$ Proline : int 1065 1050 1185 1480 735 1450 1290 1295 1045 1045 ...
還有一個vector
wine.class
包含定性wine.class
可變的178點意見:
str(wine.class)
Factor w/ 3 levels "barolo","grignolino",..: 1 1 1 1 1 1 1 1 1 1 ...
的13個定量變量用於計算PCA:
wine.pca <- prcomp(wine, scale. = TRUE)
而wine.class
變量只是用於顏色點上的點
感謝您的耐心等待。所以'wine'和'wine.class'必須分開才能運行'pca'分析。因此,在下面的代碼中,R如何知道在哪裏查找'wine.class'將它們放在一起。 ggbiplot(wine.pca,obs.scale = 1,var.scale = 1, groups = wine.class,ellipse = TRUE,circle = TRUE)+ scale_color_discrete(name ='')+ theme(legend.direction ='horizontal',legend.position ='top')'當我加載數據時,我只能加載'wine',而不是'wine.class'。 –
當你做'數據(葡萄酒)'時,'wine.class'加載以及'wine''data.frame'。並且它是'groups = wine.class',它使顏色和elipses(嘗試刪除它) – HubertL
哦,我明白了。所以它們被鏈接,但不一定顯示在一張表中。非常感謝 –
你可以看到在環境,'wine.class'是一個矢量,當你調用'數據(葡萄酒)時加載' – HubertL
感謝您的回答。是的,'wine.class'確實顯示爲一個媒介。你會詳細說明嗎?我將數據集導出爲csv文件,但wine.class信息不可見 –