Creating Convex Hulls

Please see the FAQ: What's a reproducible example (`reprex`) and how do I create one? Using a reprex, complete with representative data will attract quicker and more answers.

Here's an example of convex hull construction from this S/O post

library(tidyverse)

# Find the convex hull of the points being plotted
hull <- mtcars %>%
  slice(chull(mpg, wt))

# Define the scatterplot
p <- ggplot(mtcars, aes(mpg, wt)) + geom_point(shape = 21)

# Overlay the convex hull
p + geom_polygon(data = hull, alpha = 0.5)

Created on 2020-03-25 by the reprex package (v0.3.0)