Displaying 1 result from an estimated 1 matches for "distancecalc".
2012 Aug 01
3
repeating a function across a data frame
...ate any advice!
Here's what I'm doing:
I have some data: 40 samples, ~460 000 different readings between 1 and 0
for each sample. I would like to make R spit out a matrix of distances
between the samples. So far, I have made a function to calculate the
distance between any two samples:
DistanceCalc<-function(x,y){#x and y are both vectors - the entire reading
set for sample x and
#sample y, respectively
distance<-sqrt(sum((x-y).^2))
distanceCorrected<-distance/sqrt(length(x))#to force the maximum possible
value to =1
print(distanceCorrected)
}
The next thing I want to do is to...