how to group data by LatLong distance in R
问题 I have a function distance(lat1,lon1, lat2,lon2) that calculates the distance of 2 points. Suppose I have a dataframe with some points and values: n<-c(lon = -1.729219, lat = 29.730836) o<-c(lon = -5.041928, lat = 28.453022) e<-c(lon = -2.700067, lat = 29.198922) s<-c(lon = -5.212864, lat = 28.531739) centro<-matrix(c(n,o,e,s), ncol=2, byrow=TRUE) d<-data.frame(c=centro, amount=c(3.5,3.5,3.5,3.5), count=c(12,12,12,12)) colnames(d)<-c('lon','lat','amount','count') I want to get a a new