Skip to content
Prev 2811 / 7419 Next

Calculate similarity matrix for category data in R

On 24/02/2012, at 11:36 AM, Yong Zhang wrote:

            
Yong,

You can do this with function taxa2dist() in vegan.

If your taxonomic levels are factors (instead of characters), you can also use daisy() in the cluster package. 

vegan::taxa2dist with default settings and cluster::daisy will give linearly related results. However, vegan::taxa2dist results are scaled to maximum=100 and cluster::daisy to maximum=1. Moreover, cluster::daisy will regard all species in the same genus as identical (dissimilarity = 0) unless you also have a factor for species. In contrast, vegan::taxa2dist will not give zero dissimilarities, but all rows will be regarded as different (species).

Cheers, Jari Oksanen