Let's use sf::st_distance() suggested by @nniloc
Let's prepare sample occurrence data:
occ <- rgbif::occ_data(
  scientificName = "Calystegia pulchra", 
  country = "GB", 
  hasCoordinate = TRUE
)
occ <- head(occ$data, 220) |>
  sf::st_as_sf(coords = c("decimalLongitude", "decimalLatitude"), crs = 4326) |>
  subset(select = c("key", "scientificName"))
Let's create a distance matrix
m <- sf::st_distance(occ)
m[1:4, 1:4]
#> Units: [m]
#>          [,1]      [,2]      [,3]     [,4]
#> [1,]      0.0 127215.11 202758.86 763395.9
#> [2,] 127215.1      0.00  98557.85 681999.6
#> [3,] 202758.9  98557.85      0.00 583484.0
#> [4,] 763395.9 681999.59 583484.00      0.0
and function, which takes the row, and calculates how much entries where the  distance > ...
how_much <- function(matrix = m, row = 1, distance = 100000) {
  length(which({{matrix}}[{{row}},] > units::as_units({{distance}}, "m")))
  }
how_much(m, 2, 100000)
#> [1] 195
Let's add it to our occurrence data:
occ |>
  dplyr::mutate(row_number = dplyr::row_number()) |>
  dplyr::rowwise() |>
  dplyr::mutate(dist_200000 = how_much(m, row_number, 200000))
#> Simple feature collection with 220 features and 4 fields
#> Geometry type: POINT
#> Dimension:     XY
#> Bounding box:  xmin: -7.978369 ymin: 49.97314 xmax: 1.681262 ymax: 57.90633
#> Geodetic CRS:  WGS 84
#> # A tibble: 220 × 5
#> # Rowwise: 
#>    key        scientificName                       geometry row_number dist_20…¹
#>  * <chr>      <chr>                             <POINT [°]>      <int>     <int>
#>  1 3320924569 Calystegia pulchra Brum…  (-0.17902 51.49553)          1       196
#>  2 3437494613 Calystegia pulchra Brum… (-1.962333 51.78564)          2       158
#>  3 3785877810 Calystegia pulchra Brum…  (-2.541045 52.5979)          3       146
#>  4 3352641836 Calystegia pulchra Brum… (-6.189535 57.41207)          4       171
#>  5 3338086543 Calystegia pulchra Brum… (-2.302697 53.20301)          5       154
#>  6 3352720276 Calystegia pulchra Brum…  (-3.052632 54.8225)          6       147
#>  7 3352736637 Calystegia pulchra Brum… (-1.614114 55.37932)          7       164
#>  8 3384449063 Calystegia pulchra Brum… (-4.681922 57.14801)          8       135
#>  9 3421262904 Calystegia pulchra Brum…  (-6.19056 57.42103)          9       171
#> 10 3392248456 Calystegia pulchra Brum… (-6.159327 56.11731)         10       158
#> # … with 210 more rows, and abbreviated variable name ¹dist_200000
Regards,
Grzegorz
Created on 2022-10-04 with reprex v2.0.2