## Loading required package: pacman
# I created a data frame placing within it, "cover", "code", "transect"
df <- data.frame(
  value_cover = c(CCPlant$cover),
  value_code = c(CCPlant$code),
  group_trans = c(CCPlant$transect)
)

# I used this function to compare percentage of value_num to value_chr
compare_percentage <- function(value_cover, value_code) {
  percentage <- value_cover / sum(value_cover) * 100
  paste0(value_code, ": ", round(percentage, 2), "%")
}

# I then applied the function (df) and grouped it by transect
result <- df %>%
  group_by(group_trans) %>%
  mutate(comparison = compare_percentage(value_cover, value_code))



ggplot(data = df, aes(x = value_code)) +
  geom_bar() +
  labs(title = "Plant Coverage",
       x = "Species",
       y = "Coverage (%)") +
  theme(axis.text.x = element_text(angle = 90, hjust = 1))