Skip to content
Back to formatted view

Raw Message

Message-ID: <A4C6150A-85A4-41F2-8D55-F2E60F8BDE91@comcast.net>
Date: 2009-11-12T20:33:10Z
From: David Winsemius
Subject: Dist function
In-Reply-To: <32322DD8-C01A-44CE-A7FE-8CCC0B7FCA27@comcast.net>

On Nov 12, 2009, at 1:32 PM, David Winsemius wrote:

>
> On Nov 12, 2009, at 1:20 PM, Caio Azevedo wrote:
>
>> Hi all,
>>
>> Does anybody know which distance measure is used when the option
>> ""method="binary" "" is considered in the "dist" function?
>
> Did you look at the help page?

If you are having problems understanding the dist help page. then  
perhaps you can think of the binary distance as the Boolean sum of  
XOR() divided by the sum of OR():

 > sum( xor(c(1,0,1,0), c(1,1,1,0))+0) / sum( c(1,0,1,0) |  
c(1,1,1,0)+0 )
[1] 0.3333333

Or using the example on the help page:

 > x <- c(0, 0, 1, 1, 1, 1)
 > y <- c(1, 0, 1, 1, 0, 1)
 > dist(rbind(x,y), method= "binary")
     x
y 0.4
 > ## answer 0.4 = 2/5

 > sum(xor(x, y)+0)/sum(x | y +0)
[1] 0.4


>
-- 

David Winsemius, MD
Heritage Laboratories
West Hartford, CT