[R] Distance between a vector and matrix rows
    vioravis 
    vioravis at gmail.com
       
    Mon Aug  8 09:02:27 CEST 2011
    
    
  
I am trying to find the distance between a vector and each row of a
dataframe. I am using the function "distancevector" in the package "hopach"
as follows:
mydata<-as.data.frame(matrix(c(1,1,1,1,0,1,1,1,1,0),nrow=2))
 V1 V2 V3 V4 V5
1  1  1  0  1  1
2  1  1  1  1  0
vec <- c(1,1,1,1,1)
d2<-distancevector(mydata,vec,d="euclid")
The Euclidean distance between the two rows of the data frame to the vector
should be 1. But I am getting 0.4472136 for both.
Can someone please point out the reason for the discrepancy???
Also, are there other packages for calculating the distance between a binary
vector and all the rows of a data frame (contains only binary values)? 
Thank you.
Ravi
--
View this message in context: http://r.789695.n4.nabble.com/Distance-between-a-vector-and-matrix-rows-tp3726268p3726268.html
Sent from the R help mailing list archive at Nabble.com.
    
    
More information about the R-help
mailing list