[R] R cycle to calculate distances

P.Branco pjlbranco at yahoo.com
Mon Nov 17 15:24:34 CET 2008


Dear all,

I am for the first time trying to work with R, but I have bumped into a
problem.

I have four vectors:
r1 (49 values)
r21 (49 values)
r22 (49 values)
r3 (49 values)
s1 (300 values)
s21 (300 values)
s22 (300 values)
s3 (300 values)

And I would like to calculate the distances from all references (r) sites to
sample (s) site, for that I wrote this equation:

drs=sqrt(((0.723523*(r1[i]-s1[ii]))^2)+(((-0.215518*(r21[i]-s21[ii]))^2)+((0.518612*(r22[i]-s22[ii]))^2))+((0.283655*(r3[i]-s3[ii]))^2))

Now how can I run a cycle in order to calculate the distances?

Could you please help me?

P. Branco

-- 
View this message in context: http://www.nabble.com/R-cycle-to-calculate-distances-tp20540340p20540340.html
Sent from the R help mailing list archive at Nabble.com.



More information about the R-help mailing list