Reputation: 13
I write you because I am wasting a lot of time trying to label my data “sites” in the triplot after the analysis of a Canonical correspondence analysis(CCA). My database consists on comparing two seasons (Season1 and Season2) with three different layers across the water column and 9 biotic variables and 9 abiotic variables. From 1 to 28rows correspond to first season and from 29 to 49 rows to second season. In every season, there are samples from epilimnion, metalimnion and hypolimnion (the different water column layers).
My code for the CCA analysis:
library(ggplot2)
library(vegan)
library(matrixStats)
my labels
abioticlabel<-cbind(ab[,-(1:9)])
abioticlabel
Code2 Code
1 Epi 1
2 Epi 1
3 Epi 1
4 Meta 2
5 Meta 2
6 Meta 2
7 Hypo 3
8 Epi 1
9 Epi 1
10 Epi 1
11 Meta 2
12 Meta 2
###……till 49 cells…
My labels code
label <- aggregate(abioticlabel[,-(1:10)],list(group=ab$Code2),mean)
label
# group
# 1 Epi
# 2 Hypo
# 3 Meta
CCA code
spe.cca<-cca(b~.,data=abiotic_data)
So, my doubt comes when I want to create the triplot, which consists on: 1. Plot A: points for sites (The sites are the rows, n = 49….) 2. Plot B: points for variables “sp”. (My variables are 9 in total) 3. Plot C: arrows of quantitative explanatory variables
Triplot results:
plot(spe.cca, display=c("sp","lc","cn"), scaling=2, xlab="CCA1 ()", ylab="CCA2 ()")
Since I want to change the triplot for another more attractive looking plot,I create a code for every plot (In total 3). For this reason, I downloaded the next packages:
library(ggplot2)
library(FactoMineR)
library(factoextra)
(With these packages, at the beginning I had few problems as well and I had to update my R version to 3.5.2).
The steps for the “Plot A” are:
Make plotting space
par(mar=c(4,4,2,2))
plot(spe.cca, scaling=2, display=c("sp","lc","cn"),type="n",
+ xlab="CCA1", ylab="CCA2")
Plot A) Points for "sites"
code5 <- scores(spe.cca, choices=1:2, scaling=2, display="lc")
points(code5, pch=1, cex=1.5)
mycode<-scale_color_manual(labels,breaks = c("Epi", "Meta", "Hypo"),
values=c("white", "grey", "black"))
“mycode” is because my idea of the label code is this:
Results:
Since I did not get it, I tried several codes, following the link that I attach, but I did not get any success, :-S . So, could someone tell me where I have to specify the code that I want for my “sites”?
Link
This is my R info session
sessionInfo()
R version 3.5.2 (2018-12-20)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows 10 x64 (build 17134)
Upvotes: 1
Views: 918