Search code examples
rdata-structuresvegan

convert a list -class numeric- into a distance structure in R


I have a list that looks like this, it is a measure of dispersion for each sample.

         1          2          3          4          5 
0.11829384 0.24987017 0.08082147 0.13355495 0.12933790 

To further analyze this I need it to be a distance structure, the -vegan- package need it as a 'dist' object.

I found some solutions that applies to matrices > dist, but how could I change this current data into a dist object?

I am using the FD package, at the manual I found,

Still, one potential advantage of FDis over Rao’s Q is that in the unweighted case (i.e. with presence-absence data), it opens possibilities for formal statistical tests for differences in FD between two or more communities through a distance-based test for homogeneity of multivariate dispersions (Anderson 2006); see betadisper for more details

I wanted to use vegan betadisper function to test if there are differences among different regions (I provided this using element "region" with column "region" too)

functional <- FD(trait, comun)
mod <- betadisper(functional$FDis, region$region)

using gowdis or fdisp from FD didn't work too.

distancias <-  gowdis(rasgo)
mod <- betadisper(distancias, region$region)
dispersion <- fdisp(distancias, presence)
mod <- betadisper(dispersion, region$region)

I tried this but I need a list object. I thought I could pass those results to betadisper.


Solution

  • You cannot do this: FD::fdisp() does not return dissimilarities. It returns a list of three elements: the dispersions FDis for each sampling unit (SU), and the results of the eigen decomposition of input dissimilarities (eig for eigenvalues, vectors for orthonormal eigenvectors). The FDis values are summarized for each original SU, but there is no information on the differences among SUs. The eigen decomposition can be used to reconstruct the original input dissimilarities (your distancias from FD::gowdis()), but you can directly use the input dissimilarities. Function FD::gowdis() returns a regular "dist" structure that you can directly use in vegan::betadisper() if that gives you a meaningful analysis. For this, your grouping variable must be based on the same units as your distancias. In typical application of fdisp, the units are species (taxa), but it seems you want to get analysis for communities/sites/whatever. This will not be possible with these tools.