So i have a matrix that was generated using the distm() function to generate the distance between stations in a datatable and apply the minimum distance of each station to a new datatable but because it also compares each station with it self it has 0 as the minimum value for each row in the matrix. So i'm looking for a way to get rid of the 0's.
This is what i've used to generate the matrix:
library(geosphere)
mDis = distm( nStnData[,c("Longitude", "Latitude")], nStnData [,c("Longitude", "Latitude")], fun = distVincentyEllipsoid)
This is how i'm trying to apply the minimum distance for each station to the new datatable:
t$minDistance = apply(mDis, 1, min)
This is what it saves: 1