Agree with @PereG on answer above, but think that the order of latitude and longitude is the other way around: lon, lat. This will affect your results for distance matrix. So correct is:
library(geosphere)
distm (c(lon1, lat1), c(lon2, lat2), fun = distHaversine)
Source: ftp://cran.r-project.org/pub/R/web/packages/geosphere/geosphere.pdf