calculating the geographic distance between coordinates

Dear fellow R users,
I have a matrix where column 1 is longitude, and column 2 is latitude. Each row also has a name, simply numbers from 1 to 837. I want to calculate the geographical distance between each row of the matrix, so row 1 with row 2, row 1, with row3 and so on, so that I end up with a matrix of the distance between each point. I think I should use the geosphere package and then distm, but I am not sure how to proceed afterwards - should I do a looping function for each row to calculate distance? I am very new to R and in over my head so please let me know if you have any tips :slight_smile: