How to use R to compute Tanimoto/Jacquard Score as distance matrix

旧巷老猫 提交于 2019-12-21 05:41:05

问题


I would like to calculate the distance matrix of the rows in an array in R using Tanimoto/Jacquard Score as distance matrix.

Is it possible to be done? If yes, could you mind to teach me how to do it?


回答1:


vegan package has a vegdist function that can calculate, among other things, the Jaccard index. Assuming that's what you're after. It's use is pretty straightforward.

library(vegan)
data(varespec)
vare.dist <- vegdist(varespec, method = "jaccard")

Other available methods are

method   Dissimilarity index, partial match to "manhattan", "euclidean",
 "canberra", "bray", "kulczynski", "jaccard", "gower", "altGower", "morisita",
 "horn", "mountford", "raup" , "binomial" or "chao"



回答2:


I think you're going to have a lot more luck searching for "Jaccard" rather than "Jacquard".

  • Install the 'sos' package (install.packages("sos"))
  • Search for functions with these strings (library(sos); findFn("tanimoto jaccard")).
  • Poke through the results for something suitable (it looks to me like this is probably your best option; install.packages("ade4"); library("ade4"); ?dist.binary)
  • If you can't figure out how to use it, edit your question, giving a small reproducible example of what you want to do.


来源:https://stackoverflow.com/questions/5597305/how-to-use-r-to-compute-tanimoto-jacquard-score-as-distance-matrix

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!