我還是R的新手,試圖學習如何使用庫素食主義者,我可以使用正常的繪圖功能輕鬆繪製R圖。當我想在ggplot中繪製數據時出現問題。我知道我必須從我創建的列表中提取正確的數據,但是哪些和如何?我一直在練習上的數據集可以在這裏https://drive.google.com/file/d/0B1PQGov60aoudVR3dVZBX1VKaHc/view?usp=sharing 下載我一直在使用得到轉化數據的代碼是這樣的:在ggplot中繪製RDA(素食主義者)
library(vegan)
library(dplyr)
library(ggplot2)
library(grid)
data <- read.csv(file = "People.csv", header = T, sep = ",", dec = ".", check.names = F, na.strings=c("NA", "-", "?"))
data2 <- data[,-1]
rownames(data2) <- data[,1]
data2 <- scale(data2, center = T, scale = apply(data2, 2, sd))
data2.pca <- rda(data2)
,給了我一個名單,我可以積使用基本「劇情」和「biplot」函數,但是我不知道如何在ggplot中繪製PCA和雙標圖。我還想按組對數據點着色,例如,性別。任何幫助都會很棒。
謝謝你的回答@jlhoward,雖然雙標圖與我從雙標圖函數中得到的不同 - 在我的雙標圖中某些矢量更長?文字還是很煩人的,我猜這有沒有簡單的解決辦法呢? –
該解決方案的主要問題是軸沒有相等的寬高比。我自己不使用'ggplot2',但它必須有一種設置寬高比的方法。使用'scores()'來訪問縮放的排序結果也更好 - 'summary()'是如此的複雜。 –
也許有助於看看https://github.com/gavinsimpson/ggvegan中的ggvegan包 –