vegan

how to make a loop function with “adonis”?

北城以北 提交于 2019-12-08 16:29:37
data(dune) data(dune.env) results<-list() for (i in colnames(dune.env)){ results[[i]]<- adonis(dune ~ i, data=dune.env, permutations=99) } When I test each name in colnames(dune.env) , it can work. But it can not work in the loop function above. I think it is due to the i in the loop fuction has " " . How to fix it? Thanks. I know nothing about adonis, but I do know that formulas are language objects which do not take nicely to being treated as though they were ordinary character objects. for (i in colnames(dune.env)){ form <- as.formula(paste("dune", i, sep="~")) results[[i]]<- adonis(form,

Including arrows in NMDS plot in R vegan package

走远了吗. 提交于 2019-12-08 10:45:24
问题 I'm using the vegan package to plot a NMDS in R analyzing community similarities. This is based on a community matrix that includes different treatments: NMDS=metaMDS(community_matrix,k=2,trymax=100) plot(NMDS) Could anybody tell me how to I can draw arrows to show how individual species respond to treatments? 回答1: Arrows would be the wrong interpretation in such a plot; there is no reason whatsoever to assume that in a plot best preserving rank-order dissimilarity of samples the species

how to make a loop function with “adonis”?

拟墨画扇 提交于 2019-12-08 07:52:16
问题 data(dune) data(dune.env) results<-list() for (i in colnames(dune.env)){ results[[i]]<- adonis(dune ~ i, data=dune.env, permutations=99) } When I test each name in colnames(dune.env) , it can work. But it can not work in the loop function above. I think it is due to the i in the loop fuction has " " . How to fix it? Thanks. 回答1: I know nothing about adonis, but I do know that formulas are language objects which do not take nicely to being treated as though they were ordinary character objects

vegan dbrda species scores are empty despite community matrix provided

我的梦境 提交于 2019-12-06 11:35:58
问题 I have performed "Distance based redundancy analysis" (dbRDA) in R using the vegan community ecology package. I would like to show the relative contribution of (fish) trophic groups to the dissimilarity between samples (abundance data of trophic level fish assemblages) in an ordination plot of the dbRDA results. I.e. Overlay arrows and trophic level group names onto the ordination plot, where the length of the arrow line indicates the relative contribution to dissimilarity. This should be

ANOSIM in Vegan is not working

泄露秘密 提交于 2019-12-04 05:03:37
问题 I am trying to perform an anosim analysis in Vegan , but it doesn't seem to work... It doesn't give an error after the anosim function, but when I try to see the summary it says: Error in sort.int(x, na.last = na.last, decreasing = decreasing, ...) : 'x' must be atomic My data looks like a simple community matrix with sites and species (identical to the Dune data set). I've tried this: dist.com <- vegdist(data, method = "bray") an = anosim(dist.com, env) summary(an) The class of data is a

ANOSIM in Vegan is not working

风格不统一 提交于 2019-12-02 07:23:21
I am trying to perform an anosim analysis in Vegan , but it doesn't seem to work... It doesn't give an error after the anosim function, but when I try to see the summary it says: Error in sort.int(x, na.last = na.last, decreasing = decreasing, ...) : 'x' must be atomic My data looks like a simple community matrix with sites and species (identical to the Dune data set). I've tried this: dist.com <- vegdist(data, method = "bray") an = anosim(dist.com, env) summary(an) The class of data is a data.frame , the class of env is factor and the class of dist.com is dist . It is identical to the example

follow-up: Plotting ordiellipse function from vegan package onto NMDS plot created in ggplot2

自闭症网瘾萝莉.ら 提交于 2019-12-02 00:44:35
I am trying to do something similar to an old post: plotting - original post For my analysis, I am interested in whether different mammal hosts have different flea communities. The original post I have linked to has 2 different solutions for the ellipses. My problem is when I run both the 1st solution and then the general solution I get vastly different looking plots while I think they should be very similar. Below is my code. My question is: Am I doing something incorrectly or which code produces the correct figure? Or is there a better new code I should be using instead to display

accumulation curve in R

狂风中的少年 提交于 2019-11-30 23:24:53
I have data of species at 4 sites over several months. I have successfully created accumulation graphs using package vegan in R but I would like to plot all 4 sites on one graph. At first I had a data sheet with all sites and months but the when I plotted specaccum the result was a curve of accumulation of all data regardless of site. Because of this I split each site into a separate data sheet which I loaded into R. In each data sheet the first row is species names and each additional row below that is a month. For example I loaded the data of one of my sites "FMR". Then I did the following:

Plotting envfit vectors (vegan package) in ggplot2

心已入冬 提交于 2019-11-28 09:27:41
I am working on finalizing a NMDS plot that I created in vegan and ggplot2 but cannot figure out how to add envfit species-loading vectors to the plot. When I try to it says "invalid graphics state". The example below is slightly modified from another question ( Plotting ordiellipse function from vegan package onto NMDS plot created in ggplot2 ) but it expressed exactly the example I wanted to include since I used this question to help me get metaMDS into ggplot2 in the first place: library(vegan) library(ggplot2) data(dune) # calculate distance for NMDS NMDS.log<-log(dune+1) sol <- metaMDS

Plotting ordiellipse function from vegan package onto NMDS plot created in ggplot2

99封情书 提交于 2019-11-27 02:56:59
问题 Instead of the normal plot function I am using ggplot2 to create NMDS plots. I would like to display groups in the NMDS plot using the function ordiellipse() from the vegan package. Example data: library(vegan) library(ggplot2) data(dune) # calculate distance for NMDS sol <- metaMDS(dune) # Create meta data for grouping MyMeta = data.frame( sites = c(2,13,4,16,6,1,8,5,17,15,10,11,9,18,3,20,14,19,12,7), amt = c("hi", "hi", "hi", "md", "lo", "hi", "hi", "lo", "md", "md", "lo", "lo", "hi", "lo",