我从R中的数据框生成了一个排序图。数据框由站点(行)的物种(列)组成。矩阵内有一组“处理过的”站点和一组控制站点。然而,我计算排序的方式不需要矩阵中的其他变量(即没有明确的标识符表示网站被“处理或不处理”。问题:我可以按组标记图中的点而不构建分类变量吗?或者,我可以给出治疗行(例如行1:7一种符号和控件(例如8:14)另一种类型吗?
以下是一个例子:
#guess i don't have the reputation to post images...hmmm...
#looks something like this (first column is the site)
# spec1 spec2 spec3...spec14
# 1 0 1 0 ... 2
# 2 1 5 0 ... 0
# 3 0 2 1 ... 0
# .
# .
# .
# 14
# vegan package
library(vegan)
# example data matrix is 14x14, species names across columns, sites are numbered automatically upon import of txt file into RStudio
data(example)
#vegdist creates a distance matrix of sites
example.dis <- vegdist(example)
#monoMDS computes ordination of distance matrix
example.mds <- monoMDS(example.dis)
#plot it
这里我认为我可以修改图表,但我不知道该怎么做
plot(example.mds)
答案 0 :(得分:4)
是的,您可以使用外部变量来指定例如点的颜色。
以下是一个例子:
# some data
require(vegan)
data(dune)
data(dune.env)
# vector holding the colors
cols <- c("red", "blue", "pink", "green")
# NMDS with bray-curtis distance
nmds <- metaMDS(dune, "bray", 2)
# empty plot
plot(nmds, type = "n")
# Add points colored by Environmental Variable Management
points(nmds, col = cols[dune.env$Management], pch = 16)
# add legend
legend("topright", legend=levels(dune.env$Management), col=cols, pch = 16)