简体   繁体   English

如何使用R来计算Tanimoto / Jacquard Score作为距离矩阵

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

I would like to calculate the distance matrix of the rows in an array in R using Tanimoto/Jacquard Score as distance matrix. 我想用Tanimoto / Jacquard Score作为距离矩阵来计算R中数组中行的距离矩阵。

Is it possible to be done? 有可能吗? If yes, could you mind to teach me how to do it? 如果是的话,你能介意教我怎么做吗?

vegan package has a vegdist function that can calculate, among other things, the Jaccard index. vegan包有一个vegdist函数,可以计算Jaccard指数等。 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"

I think you're going to have a lot more luck searching for "Jaccard" rather than "Jacquard". 我认为你会有更多的运气寻找“Jaccard”而不是“Jacquard”。

  • Install the 'sos' package ( install.packages("sos") ) 安装'sos'包( install.packages("sos")
  • Search for functions with these strings ( library(sos); findFn("tanimoto jaccard") ). 使用这些字符串搜索函数( 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 ) 通过结果install.packages("ade4"); library("ade4"); ?dist.binary合适的东西(在我看来, 可能是你最好的选择; 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. 如果您无法弄清楚如何使用它,请编辑您的问题,给出一个可重复的小例子,说明您想要做什么。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM