首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >如何向NMDS排序添加新的点?

如何向NMDS排序添加新的点?
EN

Stack Overflow用户
提问于 2020-07-10 00:25:35
回答 1查看 70关注 0票数 1

我想看看如果我从一个或n个植物地块中移除一个或n个树种,这个地块是如何排列的。我使用了vegan包中的metaMDS函数,我想添加新的绘图,就像predict.cca函数在cca之后所做的那样。

在执行metaMDS之前,我尝试只合并我的两个data.frame (原始的和修改的),但排序移动了很多。

有谁知道如何做到这一点?

下面是我的问题的一个可重现的例子:

代码语言:javascript
复制
library(vegan)
data(dune)
#the original NMDS :
NMDS <- metaMDS(dune)
plot(NMDS$points)
text(NMDS$points,labels = 1:nrow(dune))

#The suppression of one random occurence on the first plot (for instance) :
occurence_1 <- which(dune[1,]!=0) #the col number where species occur in plot 1
dune_1_mod <- dune[1,]
dune_1_mod[,sample(occurence_1,size = 1)] <- 0 

#Then I would like to have a function "predict.MDS" (that I unfortunately don't know) where I could do that :
dune_1_mod_coordinates <- predict.MDS(NMDS, newdata = dune_1_mod)

#which would provide me the coordinates of my modified plot in the previous NMDS ordination and allow me to plot it on the same plot :
points(x = dune_1_mod_coordinates$points[,1], y = dune_1_mod_coordinates$points[,2])

#I tried to just add some new modified plot, run the MDS on the whole dataset and plot it, but it seems that the ordination is deeply modified and driven by the characteristics of the new modified plots
#see here :

plot(NMDS$points)
text(NMDS$points,labels = 1:nrow(dune))

occurence_1 <- which(dune[1,]!=0)

dune2 <- dune
for(i in 1:length(occurence_1))
{
  dune2[i+nrow(dune),] <- dune2[1,] 
  dune2[i+nrow(dune),occurence_1[i]] <- 0 
}
NMDS2 <- metaMDS(dune2)
plot(NMDS2$points,col=c(rep(1,nrow(dune)),rep(2,length(occurence_1))))
text(NMDS2$points,labels = c(1:nrow(dune),rep(NA,length(occurence_1))))
EN

回答 1

Stack Overflow用户

发布于 2020-11-14 00:09:59

这是可以做到的,但在素食中没有实现。让它保持不实现的原因是用户界面会很麻烦。我自己做,但我可以承受UI的痛苦。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/62819389

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档