Hi all,
I want to do a PCA and RDA with my sites coloured. I try this code to write my sites and the color I want for theses sites but doesn't work
For my RDA
spe.rda <- rda(Spe~., data = Env)
windows()
plot(spe.rda, scaling=2, main="Triplot RDA (scaling 2)", xlim=c(-2,1.5), ylim=c(-1.25,1.5))
h=rownames(Env)
col[h=="A1" | h=="A7" | h=="A3" | h=="A4" | h=="A5"] = "darkgreen"
col[h=="A6" | h=="A2"] = "red"
text(Env, display = "sites", col = col)
For my PCA
res.pca <- prcomp(Env[,5:13], scale = TRUE)
fviz_pca_var(res.pca,
col.var = "cos2",
gradient.cols = c("#00AFBB", "#E7B800", "#FC4E07"),
repel = TRUE
) +
h=rownames(Env)
col[h=="A1" | h=="A7" | h=="A3" | h=="A4" | h=="A5"] = "darkgreen"
col[h=="A6" | h=="A2"] = "red"
text(Env, display = "sites", col = col)
Thanks