if (requireNamespace("pracma")) {
# Make a grid to sample from
grd <- sf::st_make_grid(n = c(1, 1), cellsize = c(100, 100), offset = c(0,0))
# sample 100 points
pnts <- sf::st_sample(grd, 100)
cm <- center_mean(pnts)
em <- euclidean_median(pnts)
cmed <- center_median(pnts)
plot(pnts)
plot(cm, col = "red", add = TRUE)
plot(em, col = "blue", add = TRUE)
plot(cmed, col = "green", add = TRUE)
}
Run the code above in your browser using DataLab