I've created an NMDS plot using vegan but I'm having trouble adding convex hulls. I need three hulls: one for Decatur (D610F, D15F, D15B, etc.), one for Hickory Road (HR610F, HR15F, HR15B, etc.), and one for Cedartown (C610F, C15F, C15B, etc.). Any help would be greatly appreciated. I'll add the codes I've used below along with a screenshot of my graph. Thank you in advance.
#NMDS analyses
WD <- "C:/Users/jacob/OneDrive/Documents/R/win-library/3.6/vegan/data"
setwd(WD)
require(vegan)
phylum.dat <- read.csv("Phylum data for R.csv", stringsAsFactors = T, header = T, row.names = 1)
diversity(phylum.dat, index = "shannon")
specnumber(phylum.dat) #species number
beta <- vegdist(phylum.dat, "jaccard", binary = TRUE) #jaccard distance
mean(beta)
dist(beta) #distance matrix
NMDS <- metaMDS(beta, distance = "jaccard", k = 2)
plot(NMDS, display = "sites", type = "text") #adds labels to plot
suppressPackageStartupMessages(library(dplyr))
library(ggplot2)
hull_cyl <- mtcars %>%
group_by(cyl) %>%
slice(chull(mpg, wt))
# Define the scatterplot
p <- ggplot(mtcars, aes(mpg, wt)) + geom_point(shape = 21)
# Update the plot with a fill group, and overlay the new hulls
p + aes(fill = factor(cyl)) + geom_polygon(data = hull_cyl, alpha = 0.5)