The following objects are masked from 'package:stats':
filter, lag
The following objects are masked from 'package:base':
intersect, setdiff, setequal, union
# Create a sample ecological datasetdata <-data.frame(Species =rep(c("Species A", "Species B", "Species C"), each =10),Abundance =c(rpois(10, 5), rpois(10, 10), rpois(10, 15)),Location =rep(c("Site 1", "Site 2"), each =15))# Summarize data by speciessummary_data <- data %>%group_by(Species) %>%summarize(Mean_Abundance =mean(Abundance), .groups ='drop')# Print summaryprint(summary_data)
# A tibble: 3 × 2
Species Mean_Abundance
<chr> <dbl>
1 Species A 5.1
2 Species B 10.3
3 Species C 15.2
# Plot species abundance by locationggplot(data, aes(x = Species, y = Abundance, fill = Location)) +geom_boxplot() +labs(title ="Species Abundance by Location",x ="Species",y ="Abundance") +theme_minimal()