```{css zoom-lib-src, echo = FALSE} script src = "https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js"
```{js zoom-jquery, echo = FALSE} $(document).ready(function() { $('body').prepend('<div class=\"zoomDiv\"><img src=\"\" class=\"zoomImg\"></div>'); // onClick function for all plots (img's) $('img:not(.zoomImg)').click(function() { $('.zoomImg').attr('src', $(this).attr('src')).css({width: '100%'}); $('.zoomDiv').css({opacity: '1', width: 'auto', border: '1px solid white', borderRadius: '5px', position: 'fixed', top: '50%', left: '50%', marginRight: '-50%', transform: 'translate(-50%, -50%)', boxShadow: '0px 0px 50px #888888', zIndex: '50', overflow: 'auto', maxHeight: '100%'}); }); // onClick function for zoomImg $('img.zoomImg').click(function() { $('.zoomDiv').css({opacity: '0', width: '0%'}); }); });
knitr::opts_knit$set(root.dir=here::here()) knitr::opts_chunk$set(warning=FALSE, message=FALSE, echo=FALSE, results=FALSE,fig.width=6, fig.height=5) knitr::opts_chunk$set( collapse = TRUE, comment = "#>" ) library(tidyverse) library(scales) library(SARA)
This is intended to show some rudimentary ways to access the stock assessment results archive.
This function likely depends on R version >=4.0.
Ensure that the "devtools" package from CRAN is installed
# Install and load devtools package install.packages("devtools") library("devtools")
Next, install the SARA package from this GitHub repository using a function in the "devtools" package. This may require using the INSTALL_opts
option depending upon your version of R:
# Install package install_github("afsc-assessments/SARA", INSTALL_opts="--no-staged-install") # Load package library(SARA)
Invoking SARA()
will filter through the individual assessment result files in
the data-raw directory and create a number of dataframes.
library(SARA)
SARA()
df<-tibble(left_join(mod_stats,sara_stock));names(df) <- tolower(names(df))
glimpse(df)
df |> filter(assessyear==2021) |> ggplot(aes(x=spawnbiomass,y=recruitment,label=fisheryyear)) +
geom_point(size=.2) + geom_smooth() + theme_minimal() + facet_wrap(stock~region,scale="free")
SARA() df<-tibble(left_join(mod_stats,sara_stock)); names(df) <- tolower(names(df)) df |> filter(assessyear>=2019) |> mutate(Assessed_Year=as.factor(assessyear), Year=fisheryyear,SSB=spawnbiomass) |> ggplot(aes(y=SSB,x=Year,label=Year,color=Assessed_Year)) + geom_line(stat='Identity',width=2) + theme_minimal() + facet_wrap(stock~region,scale="free") + expand_limits(y = 0)
df<-tibble(left_join(mod_stats,sara_stock)); names(df) <- tolower(names(df)) df |> filter(assessyear==2021) |> ggplot(aes(x=spawnbiomass,y=recruitment,label=fisheryyear)) + geom_point(size=.2) + geom_smooth() + theme_minimal() + facet_wrap(stock~region,scale="free")
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.