st_distance() from the sf package will do this for you. If you're looking for more specific help, please post a sample of your data.
st_distance()