Мне нужно добавить три вектора (соленость, температура и pH) к моему графику NMDS. Вот мой код для моего графика NMDS:
#make community matrix - extract columns with abundance information
com = pc[,4:ncol(pc)]
#turn abundance data frame into a matrix
m_com = as.matrix(com)
nmds = metaMDS(m_com, distance= "bray")
plot(nmds)
#extract NMDS scores (x and y coordinates)
data.scores = as.data.frame(scores(nmds))
#add columns to data frame
data.scores$Sample = pc$taxon
data.scores$Station = pc$Station
data.scores$Time = pc$Time
head(data.scores)
library(ggplot2)
xx = ggplot(data.scores, aes(x = NMDS1, y = NMDS2)) +
geom_point(size = 7, aes( colour = Time, shape = Station))+
theme(axis.text.y = element_text(colour = "black", size = 10, face = "bold"),
axis.text.x = element_text(colour = "black", face = "bold", size = 10),
legend.text = element_text(size = 10, face ="bold", colour ="black"),
legend.position = "right", axis.title.y = element_text(face = "bold", size = 10),
axis.title.x = element_text(face = "bold", size = 10, colour = "black"),
legend.title = element_text(size = 10, colour = "black", face = "bold"),
panel.background = element_blank(), panel.border = element_rect(colour = "black", fill = NA, size = 1.2),
legend.key=element_blank()) +
labs(x = "NMDS1", colour = "Time", y = "NMDS2", shape = "Station") +
scale_shape_manual(values = c(15,16,17,18,8)) +
scale_color_manual(values = c("green", "grey", "black", "mediumblue", "red", "orange"))
plot(xx)
Вот пример таблицы, которую я хотел бы использовать для добавления трех векторов в зависимости от станции.
Station Temp Salinity pH
S4S1 27.86 6.84 7.83
S5S1 28.92 7.84 7.92
S1S4 25.78 4.09 7.71
S3S4 27.34 4.16 8.36
Любая помощь очень ценится.