In R, I need to calculate the distance between a coordinate and all the other coordinates.
I have a dataset similar to this:
ID Morph Sex E N a o m 34 34 b w m 56 34 c y f 44 44
In which each "ID" represents a different animal, and E/N points represent the coordinates for the center of their home range.
I'd need to calculate the distance between each center and the centers of all the other animals. Distance with himself should not appear.
Ideally, I need to obtain two different data frames: an exhaustive one with repeated distances (a to b & b to a):
ID.1 Morph.1 Sex.1 ID.2 Sex.2 Morph.2 Dist a o m b m w 12 a o m c m y 22 b w m a m o 12 b w m c f y 13 c y f a m o 22 c y f b m w 13
And another data frame with just the non repeated distances:
ID.1 Morph.1 Sex.1 ID.2 Sex.2 Morph.2 Dist a o m b m w 12 a o m c m y 22 b w m c f y 13
It is very important to me to keep the information of Sex and Morph in the new data frames! I am interested in comparing the distances among morphs (o-o, o-w, o-y, etc).
I've been doing it in Excel using Pithagoras but I am sure there must be a relatively simple code which could help me to ignite the process in R.