Skip to content
Prev 4839 / 7420 Next

Community distance matrix deconstruction

Kate,

Your question really may need some clarification, but at the moment it looks to me that you want to have row indices and column indices for your dissimilarities, and information about within/between dissimilarities. If this is what you want to have, it is an easy task.

In the following I use a real data set from vegan to make this task a bit more general:

library(vegan)
data(mite, mite.env)
## dissimilarities
d <- dist(mite)
## row and column indices
row <- as.dist(row(as.matrix(d)))
col <- as.dist(col(as.matrix(d)))
## within same class: 1 = within, 0 = between
within <- with(mite.env, as.dist(outer(Shrub, Shrub, "==")))
## data frame -- the pedestrian way: snappier alternatives possible 
df = data.frame(row=as.vector(row), col=as.vector(col), within=as.vector(within), dist=as.vector(d))
## see it
tail(df)
#     row col within      dist
#2410  68  67      1 691.69502
#2411  69  67      0 716.93863
#2412  70  67      0 700.60973
#2413  69  68      0  78.08329
#2414  70  68      0  24.24871
#2415  70  69      1  67.86015

I don't think you really want to have this: you only believe that you want to have this (mauvaise foi, like they used to say).

If you only want to get summaries, check function meandist in vegan.

Cheers, Jari Oksanen
On 13/12/2014, at 02:17 AM, Kate Boersma wrote: