title: Euclidean distance in R using two variables in a matrix
body: <p>I am quite new to R and I am trying to compute the gross distance (or the sum of the Euclidean distance on all data points) from two variables in my matrix and net distance (Euclidean distance between the first and last point of my data. 
  So just a background on my data. My data is normally a csv file comprising of 5 variables: tracks of cells (called A), time interval, X and Y position of each cell, V=velocity. There is around 90 tracks per data and each track should be treated independent of each other.</p>
  
  <pre><code>dput(head(t1))
  structure(list(A = c(0L, 0L, 0L, 0L, 0L, 0L), T = 0:5, X = c(668L, 
  668L, 668L, 668L, 668L, 668L), Y = c(259L, 259L, 259L, 259L, 
  259L, 259L), V = c(NA, 0, 0, 0, 0, 0)), .Names = c("A", "T", 
  "X", "Y", "V"), row.names = c(NA, 6L), class = "data.frame")
  </code></pre>
  
  <p>I was not aware of the dist() function before, so I made my own function:</p>
  
  <pre><code>GD.data &lt;- function (trackdata)
  {A= trackdata(, 1); V=trackdata(, 5);
   for (i in min(A):max(A))
     while (A&lt;=i) {GD(i) = (sum (V)*(1/25))
                   return (GD(i))} 
  </code></pre>
  
  <p>This did not work. I used A as an identifier of the track and since gross distance could be also computed as:
  distance=velocity (t1-t0), I just did summation of all velocity times my time interval (since it is constantly 1/25 secs.</p>
  
  <p>How do I use the dist() function with my A as identifier? I need this since the computation of each track should be separate. Thanks!</p>