Title: | Stock Assessment Tables and Figures |
---|---|
Description: | Creates exploratory and finished tables and figures for stock assessment documents from U.S. stock assessment model outputs. This packages addresses parts of the stock assessment workflow that interprets outputs of stock assessment models as well as allows the analyst to create report ready tables and figures, reducing the need to create their own and format then when adding into a report. This package is intended to be used in conjuction with `asar`, a partially automated template for writing various stock assessment reports. Throughout development, we will be creating a set of standardized figures and tables for a stock assessment report, developing functions to produce a variety of diagonostic plots, and other helpful materials. The advantage of using this package over others is that it applies to a range of stock assessment model outputs and standardizes them. |
Authors: | Samantha Schiano, Bai Li, Steve Saul, Kelli F. Johnson, & Megumi Oshima |
Maintainer: | Samantha Schiano <[email protected]> |
License: | MIT + file LICENSE |
Version: | 0.1.0 |
Built: | 2024-11-26 16:30:27 UTC |
Source: | https://github.com/nmfs-ost/satf |
Add NOAA formatting to figure or table
add_theme(x)
add_theme(x)
x |
table or figures object from ggplot, base r plot, gt table, flextable, or kable extra |
Add the standard formatting for stock assessment reports for any figure or table. Currently, the function is able to format objects from: ggplot (ggplot2), base r plot, flextable (flextable), gt tables (gt), and kable tables (kableExtra).
add_theme(ggplot2::ggplot(data = cars, ggplot2::aes(x = speed, y = dist)) + ggplot2::geom_point())
add_theme(ggplot2::ggplot(data = cars, ggplot2::aes(x = speed, y = dist)) + ggplot2::geom_point())
Function to export a specified plot object, and its alternative text, from the R environment.
exp_fig_accessible(figure, alt_text, path, width = 5, height = 5, units = "cm")
exp_fig_accessible(figure, alt_text, path, width = 5, height = 5, units = "cm")
figure |
Plot object in the R environment to export. |
alt_text |
Alternative text for the figure. |
path |
Directory in which "exported" folder should be saved. |
width |
Plot width, in units (see argument below). Default is 5. |
height |
Plot height, in units (see argument below). Default is 5. |
units |
Plot size units (options: "in", "cm", "mm", "px"). Default is "cm". |
A folder containing exported plots and associated alternative text as .png and .csv objects, respectively.
## Not run: model_data <- read.csv(here::here("data/Petrale_sole_std_res_2023.csv")) fig1 <- satf::plot_spawning_biomass(model_data) exp_fig_accessible(figure = fig1, alt_text = "my alt text", path = here::here(), width = 5, height = 5, units = "cm") ## End(Not run)
## Not run: model_data <- read.csv(here::here("data/Petrale_sole_std_res_2023.csv")) fig1 <- satf::plot_spawning_biomass(model_data) exp_fig_accessible(figure = fig1, alt_text = "my alt text", path = here::here(), width = 5, height = 5, units = "cm") ## End(Not run)
Plot Total Biomass
plot_biomass( dat, unit_label = "metric tons", scale_amount = 1, ref_line = c("target", "MSY", "msy", "unfished"), end_year = NULL, relative = FALSE )
plot_biomass( dat, unit_label = "metric tons", scale_amount = 1, ref_line = c("target", "MSY", "msy", "unfished"), end_year = NULL, relative = FALSE )
dat |
A data frame returned from 'asar::convert_output()'. |
unit_label |
units for recruitment |
scale_amount |
indicate the exact amount of scale (i.e. 1000) |
ref_line |
A string specifying the type of reference you want to compare biomass to. The default is '"target"', which looks for '"biomass_target"' in the '"label"' column of 'dat'. The actual searching in 'dat' is case agnostic and will work with either upper- or lower-case letters but you must use one of the options specified in the default list to ensure that the label on the figure looks correct regardless of how it is specified in 'dat'. |
end_year |
last year of assessment |
relative |
A logical value specifying if the resulting figures should be relative spawning biomass. The default is 'FALSE'. 'ref_line' indicates which reference point to use. |
Plot total biomass from a stock assessment model as found in a NOAA stock assessment report. Units of total biomass can either be manually added or will be extracted from the provided file if possible. In later releases, model will not
Plot observed landings by fleet
plot_landings(dat, unit_label = "metric tons")
plot_landings(dat, unit_label = "metric tons")
dat |
A data frame returned from 'asar::convert_output()'. |
unit_label |
indicate the name of the units of landings as to label the axis |
Create a plot ready for a stock assessment report of cumulative landings over time by fleet.Includes options to plot by fleet, total observed landings with and without predicted landings. Indicate if fleet should be faceted or on one plot (default). Warning: i
Plot Recruitment
plot_recruitment( dat, unit_label = "metric tons", scale_amount = 1, end_year = NULL, n_projected_years = 10, relative = FALSE )
plot_recruitment( dat, unit_label = "metric tons", scale_amount = 1, end_year = NULL, n_projected_years = 10, relative = FALSE )
dat |
A data frame returned from 'asar::convert_output()'. |
unit_label |
units for recruitment |
scale_amount |
indicate the exact amount of scale (i.e. 1000) |
end_year |
last year of assessment |
n_projected_years |
Number of years spawning biomass is projected for. By default this number is set to 10 |
relative |
A logical value specifying if the resulting figures should be relative spawning biomass. The default is 'FALSE'. 'ref_line' indicates which reference point to use. |
Plot recruitment over time from an assessment model output file translated to a standardized output. There are options to return a ggplot2 object or export an rda object containing associated caption and alternative text for the figure.
@inheritParams plot_recruitment
plot_recruitment_deviations( dat = NULL, end_year = NULL, n_projected_years = 10 )
plot_recruitment_deviations( dat = NULL, end_year = NULL, n_projected_years = 10 )
Plot recruitment deviations relative to one over time from an assessment model output file translated to a standardized output. There are options to return a ggplot2 object or export an .rda object containing associated caption and alternative text for the figure.
@inheritParams plot_recruitment @param spawning_biomass_label Units for spawning biomass @param recruitment_label units for recruitment
plot_spawn_recruitment( dat = NULL, spawning_biomass_label = "metric tons", recruitment_label = "metric tons", end_year = NULL )
plot_spawn_recruitment( dat = NULL, spawning_biomass_label = "metric tons", recruitment_label = "metric tons", end_year = NULL )
Plot spawning recruitment relationship from a standardized output file originating from asar::convert_output()
Plot spawning biomass with a reference line as a dashed line. The figure can also be made relative to this reference line rather than in absolute units.
plot_spawning_biomass( dat, unit_label = "metric ton", scale_amount = 1, ref_line = c("target", "unfished", "msy"), end_year = NULL, relative = FALSE, n_projected_years = 10 )
plot_spawning_biomass( dat, unit_label = "metric ton", scale_amount = 1, ref_line = c("target", "unfished", "msy"), end_year = NULL, relative = FALSE, n_projected_years = 10 )
dat |
A data frame returned from 'asar::convert_output()'. |
unit_label |
units for recruitment |
scale_amount |
indicate the exact amount of scale (i.e. 1000) |
ref_line |
A string specifying the type of reference you want to compare spawning biomass to. The default is '"target"', which looks for '"spawning_biomass_target"' in the '"label"' column of 'dat'. The actual searching in 'dat' is case agnostic and will work with either upper- or lower-case letters but you must use one of the options specified in the default list to ensure that the label on the figure looks correct regardless of how it is specified in 'dat'. |
end_year |
last year of assessment |
relative |
A logical value specifying if the resulting figures should be relative spawning biomass. The default is 'FALSE'. 'ref_line' indicates which reference point to use. |
n_projected_years |
Number of years spawning biomass is projected for. By default this number is set to 10 |
Plot spawning biomass from the results of an assessment model translated to the standard output. The ggplot2 object is returned for further modifications if needed.
Create Indices of Abundance Table
table_indices(dat)
table_indices(dat)
dat |
A data frame returned from 'asar::convert_output()'. |
Create table of observed annual indices of abundance plus error stratified by fleet.