knitr::opts_chunk$set(
  collapse = TRUE,
  comment = "#>"
)
library(stocksmart)
library(magrittr)

Stock assessment time series data

Time series data for all federally managed stocks are bundled with the package

The stockAssessmentData looks like this:

stockAssessmentData %>%
  tibble::as_tibble() 

Several functions are bundled with the package to aid in filtering the data by species, region, time range, metric etc. Most functions filter using the unique species ITIS code.

Example

Problem: we want to find the latest catch data for Atlantic cod in Georges Bank from either a Benchmark assessment or a full update.

We first need to find the ITIS code for Atlantic cod. We can use the get_species_itis function to find this

get_species_itis(stock = "Atlantic cod")

There are three stocks under the jurisdiction of the NEFMC, a Georges Bank, an Eastern Georges Bank, and a Gulf of Maine stock.

Visualize data

Lets visualize all the Catch data for every assessment of the Georges Bank stock

p <- plot_ts(itis = 164712,stock = "Atlantic cod - Georges Bank",metric ="Catch",printfig=F)
p$plot

We can also plot each assessment year in its own facet

p <- plot_ts(itis = 164712,
             stock = "Atlantic cod - Georges Bank",
             metric ="Catch",
             facetplot=T,
             printfig=F)
p$plot

The facet plot is particularly useful when assessment methods have changed over time and consequently the units have also. If we plot the Abundance instead of Catch we can see how the assessment data has changed over time from Metric tons prior to 2017 to kg/tow from 2017 onward

p <- plot_ts(itis = 164712,stock = "Atlantic cod - Georges Bank",metric ="Abundance",facetplot=T,printfig=F)
p$plot

The plot_ts function returns a list of two items, a ggplot object and data frame containing the data used in the plot.

Extract latest data

Some of the assessments visualized above may not be considered Operational (Analyses conducted to provide scientific advice to fishery managers with particular focus on determining stock status and recommending catch limits - from stockSMART Data Dictionary).

We can use the ITIS code to search for the most recent Catch time series data that comes from an Operational assessment using the get_latest_metrics function. A list containing two data frames are returned.

cod <- get_latest_metrics(itis = 164712, metrics = "Catch")
cod$summary 
cod$data 

We can then filter the the data by the Gulf of Maine stock and plot it.

``` {r gom, echoo = T} cod$data %>% dplyr::filter(StockArea == "Georges Bank") %>% {. ->> filteredData} %>% ggplot2::ggplot(.) + ggplot2::geom_line(ggplot2::aes(x=Year,y = Value)) + ggplot2::ylab(filteredData %>% dplyr::distinct(Units)) + ggplot2::ggtitle(paste0("Assessment Year = ",filteredData %>% dplyr::distinct(AssessmentYear)))

```



NOAA-EDAB/assessmentdata documentation built on Nov. 30, 2024, 8:48 p.m.