K-nearest neighbor search for projected and non-projected 'sf' spatial layers. Nearest neighbor search uses (1) C implementation of the Vincenty Formula for lon-lat point layers, (2) function nn2() from package 'RANN' for projected point layers, or (3) function st_distance() from package 'sf' for line or polygon layers.
Useful links: