canberra | R Documentation |
When two vectors are given, this calculates the Canberra distance between them; This is calculated as the sum of the absolute difference between corresponding elements divided by the sum of their absolute values, for elements that are not both zero only.
canberra(x, y)
x |
A numeric vector |
y |
A numeric vector of the same dimension as x |
The Canberra distance between x and y. For example, between vectors (1,2,0) and (0,1,1), for position 1 we have (1-0)/1, for position 2 we have (2-1)/3, and for position 3 we have abs(0-1)/1, added together this results in 2 1/3, or 2.33. Note that a text distance of zero indicates that the two vectors are equal, while a text distance of 1 indicates that they have no terms in common.
canberra(c(1,2,0),c(0,1,1))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.