'R - Convex Hull Issues (ggplot)

I am trying to create a ggplot with a convex hull polygon. The data is the set of isotope values and I wanted to have the values grouped by their source.

The code I used:

ggplot(ff, aes(x=d13C, y=d34S,color=Source,shape=Source)) + geom_point()+ geom_polygon(data = ff,aes(fill =Source,colour =Source),alpha = 0.3,show.legend = TRUE)

But the convex hulls look weird and there are points not included. enter image description here

How can I get the convex hulls corrected?



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source