I'm not certain to understand what you want exactly : the distance to the furthest point (this what you ask) or the coordinates of the furthest point (this is what is provided by the answer you point to).
Here is a solution to calculate the distance (and that can easily be changed to extract the coordinates)
# This is an example for one polygon.
# NB the polygon is the same as in the answer pointed to in the question
library(sf)
sfPol <- st_sf(st_sfc(st_polygon(list(cbind(c(5,4,2,5),c(2,3,2,2))))))
center <- st_centroid(sfPol)
vertices <- st_coordinates(sfPol)[,1:2]
vertices <- st_as_sf(as.data.frame(vertices), coords = c("X", "Y"))
furthest <- max(st_distance(center, vertices))
furthest
## [1] 1.699673
# You can adapt this code into a function that will work
# for multiple polygons
furthest <- function(poly) {
# tmpfun find the furthest point from the centroid of one unique polygon
tmpfun <- function(x) {
center <- st_centroid(x)
vertices <- st_coordinates(x)[,1:2]
vertices <- st_as_sf(as.data.frame(vertices), coords = c("X", "Y"))
furthest <- max(st_distance(center, vertices))
return(furthest)
}
# We apply tmpfun on each polygon
return(lapply(st_geometry(poly), tmpfun))
}
poly1 <- cbind(c(5,4,2,5),c(2,3,2,2))
poly2 <- cbind(c(15,10,8,15),c(5,4,12,5))
sfPol <- st_sf(st_sfc(list(st_polygon(list(poly1)),
st_polygon(list(poly2)))))
furthest(sfPol)
## [[1]]
## [1] 1.699673
##
## [[2]]
## [1] 5.830952