library(rvc)
library(kableExtra)# Display a pretty table
library(ggplot2)
Quick-start
Example Workflow
“What is the mean density of Red Hind (Epinephelus guttatus) over time in St. Thomas U.S. Virgin Islands”
- load necessary libraries
- download region and years of interest
<- getRvcData(years = 2017:2023, regions = "STTSTJ") STTSTJ
- estimate density using the data object downloading from step 2
<- getDomainDensity(STTSTJ, "EPI GUTT")
RH_density
head(RH_density) %>% select(YEAR:n) %>% kable()
YEAR | REGION | SPECIES_CD | density | var | n |
---|---|---|---|---|---|
2017 | STTSTJ | EPI GUTT | 0.4459786 | 0.0038043 | 236 |
2019 | STTSTJ | EPI GUTT | 0.5158166 | 0.0030699 | 322 |
2021 | STTSTJ | EPI GUTT | 0.4815063 | 0.0028042 | 165 |
2023 | STTSTJ | EPI GUTT | 0.4351223 | 0.0020429 | 287 |
- create additional column and plot via ggplot2
%>%
RH_density mutate(SE = sqrt(var)) %>%
ggplot(aes(x = YEAR, y = density)) +
geom_line() +
geom_point(size = 2) +
geom_errorbar(aes(ymin = density - SE, ymax = density + SE),
width = 0.25,
size = 0.5) +
theme_classic()+
ylab(expression(paste("Density (ind/", m^2 ,")"))) +
xlab("Year") +
ggtitle("St. Thomas & St. John Red Hind Density") +
theme(plot.title = element_text(hjust = 0.5))