I am trying to calculate distance between two points in a three dimensional coordinate system. I have two points: 1) 'Release' (x, y, z), and 2) 'Recapture' (x, y, z). I want to calculate the euclidean distance between these two points for each recaptured individual.
My imported data set in R looks like this:
| | Rel_x | Rel_y | Rel_z | Rec_x | Rec_y | Rec_z | Distance |
|--------------|---------|---------|--------|---------|---------|--------|----------|
| Individual_1 | 231.114 | 177.002 | 17.329 | 228.288 | 178.908 | 17.243 | ? |
| Individual_2 | 239.028 | 178.789 | 16.526 | 239.057 | 178.706 | 16.499 | ? |
| Individual_3 | 212.109 | 210.142 | 18.791 | 212.300 | 208.693 | 18.372 | ? |
I also want to add a column (distance) to report the euclidean distance between the two points 'Release' and 'Recapture'.
I have tried using the dist() function but I am not sure that my line of code is correct, e.g.
dist (data_set), method = "euclidean", diag = FALSE, upper = FALSE, p = 2)
When I run this line of code, I receive the following:
Warning message: In dist(data_set) : NAS introduced by coercion
Do you have any suggestions?