| Title: | Tables and Figures for Stock Assessments |
|---|---|
| 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 Bredeck [aut, cre] (ORCID: <https://orcid.org/0009-0003-3744-6428>), Sophie Breitbart [aut, ctb] (ORCID: <https://orcid.org/0000-0001-9641-9786>), Steve Saul [aut], Kelli Johnson [ctb] (ORCID: <https://orcid.org/0000-0002-5149-451X>), Megumi Oshima [ctb] (ORCID: <https://orcid.org/0000-0002-8249-1442>) |
| Maintainer: | Samantha Bredeck <[email protected]> |
| License: | MIT + file LICENSE |
| Version: | 0.16.0 |
| Built: | 2026-11-06 21:13:23 UTC |
| Source: | https://github.com/nmfs-ost/stockplotr |
Adds a new row to an existing captions_alt_text.csv file with a label, type, caption, and alt_text for a figure or table not present in stockplotr.
add_caption_alt_text( topic_label, fig_or_table, caption, alt_text = "", dir = file.path(getwd(), "captions_alt_text.csv") )add_caption_alt_text( topic_label, fig_or_table, caption, alt_text = "", dir = file.path(getwd(), "captions_alt_text.csv") )
topic_label |
String. Figure/table label. For automated matching in asar-based report, it must match the label in your plot's chunk options, MINUS the "fig-" or "tab-". For example, the label "custom_table1" would match up properly with the "tbl-custom_table1" code chunk label. |
fig_or_table |
String. Indicates whether the object is a "table" or "figure" Options: "figure" or "table" |
caption |
String. Figure/table caption. |
alt_text |
String. Figure alternative text. Unnecessary for text-based tables. Default: "" |
dir |
Path. Path to the existing captions_alt_text.csv file that will be updated with the new caption and alt text. Default: file.path(getwd(), "captions_alt_text.csv") |
## Not run: add_caption_alt_text( topic_label = "my_topic", fig_or_table = "figure", caption = "My example figure caption.", alt_text = "My example figure alt text.", dir = file.path(getwd(), "captions_alt_text.csv") ) ## End(Not run)## Not run: add_caption_alt_text( topic_label = "my_topic", fig_or_table = "figure", caption = "My example figure caption.", alt_text = "My example figure alt text.", dir = file.path(getwd(), "captions_alt_text.csv") ) ## End(Not run)
Calculate key quantities
calc_kqs( returned_kq, prepared_data = NULL, dat = NULL, final = NULL, relative = NULL, module = NULL, ... )calc_kqs( returned_kq, prepared_data = NULL, dat = NULL, final = NULL, relative = NULL, module = NULL, ... )
returned_kq |
String. Key quantity to be returned. |
prepared_data |
Data frame. The prepared_data object. |
dat |
Data frame. The original data object. |
final |
ggplot2 object. The final figure. |
relative |
Logical. TRUE/FALSE; specify whether to set y-axis values relative to the ref_line value. |
module |
Character vector. Module name found in |
... |
Additional arguments to be passed to the function. |
The value of the specified key quantity.
## Not run: calc_kqs( returned_kq = "F.min", dat = dat ) ## End(Not run)## Not run: calc_kqs( returned_kq = "F.min", dat = dat ) ## End(Not run)
Calculate reference value point
calculate_reference_point(dat, reference_name, lbs = FALSE)calculate_reference_point(dat, reference_name, lbs = FALSE)
dat |
Data frame or list. A tibble or named list of tibbles (input as If inputting a list of tibbles, the first tibble's reference point defined
in |
reference_name |
String. Name of the reference point (e.g. "spawning biomass msy") |
lbs |
Logical. TRUE/FALSE; indicate whether to convert the y-axis values from kilograms to pounds. The default units match the default in the unit_label argument - 'mt'. Default: |
the value of the reference point name found in the dat file.
Create loop to test for differences in column values
check_label_differences(dat, index_variables, id_group = NULL)check_label_differences(dat, index_variables, id_group = NULL)
dat |
Data frame. Input data into process_table |
index_variables |
Character vector. The index_variables vector created within process_table |
id_group |
String. The identifying index variable as a string Default: NULL |
Does not change naming conventions.
conout_bam(file, out_new, fleet_names = NULL)conout_bam(file, out_new, fleet_names = NULL)
file |
Path. Assessment model output file path. Currently accepts SS3
|
fleet_names |
Character vector. Names of fleets in the assessment model as shortened in the output file or names of fleets to replace the native fleet names in the output. For example, if fleet names in the model are 1, 2, 3 then fleet_names = c("fleet1" = 1, "fleet2" = 2, "fleet3" = 3). Default: NULL |
Reshaped data frame.
Does not change naming conventions.
conout_rceattle(file, out_new, fleet_names = NULL)conout_rceattle(file, out_new, fleet_names = NULL)
file |
Path. Assessment model output file path. Currently accepts SS3
|
fleet_names |
Character vector. Names of fleets in the assessment model as shortened in the output file or names of fleets to replace the native fleet names in the output. For example, if fleet names in the model are 1, 2, 3 then fleet_names = c("fleet1" = 1, "fleet2" = 2, "fleet3" = 3). Default: NULL |
Reshaped data frame.
Does not change naming conventions. Contains code to work with SS3 Report.sso
file or returned object from r4ss::ss_output().
conout_ss3(file, out_new, fleet_names = NULL)conout_ss3(file, out_new, fleet_names = NULL)
file |
Path. Assessment model output file path. Currently accepts SS3
|
fleet_names |
Character vector. Names of fleets in the assessment model as shortened in the output file or names of fleets to replace the native fleet names in the output. For example, if fleet names in the model are 1, 2, 3 then fleet_names = c("fleet1" = 1, "fleet2" = 2, "fleet3" = 3). Default: NULL |
Reshaped data frame.
Format stock assessment output file to a standardized tibble.
convert_output(file, model = NULL, fleet_names = NULL, save_dir = NULL)convert_output(file, model = NULL, fleet_names = NULL, save_dir = NULL)
file |
Path. Assessment model output file path. Currently accepts SS3
|
model |
String. Assessment model used in evaluation Default: NULL Options: "ss3", "bam", "fims", "rceattle" |
fleet_names |
Character vector. Names of fleets in the assessment model as shortened in the output file or names of fleets to replace the native fleet names in the output. For example, if fleet names in the model are 1, 2, 3 then fleet_names = c("fleet1" = 1, "fleet2" = 2, "fleet3" = 3). Default: NULL |
save_dir |
Path. Full file path to save the converted output file. If saved file name is not indicated, the file will be saved as "std_output.rda" in the file path provided. Default: NULL |
The resulting object is a long-format, transformed and machine readable version of a model output file. Converted data frame is always returned. It will also be saved if save_dir is not NULL.
A reformatted and standardized tibble of assessment model results for application in building stock assessment reports and to easily adapt results among regional assessments.
Samantha Bredeck
## Not run: convert_output( file = here::here("model1", "Report.sso"), model = "ss3", fleet_names = c("TWL", "NONTWL"), save_dir = here::here("standard_output.rda") ) ## End(Not run)## Not run: convert_output( file = here::here("model1", "Report.sso"), model = "ss3", fleet_names = c("TWL", "NONTWL"), save_dir = here::here("standard_output.rda") ) ## End(Not run)
Create the rda package for a plot or table
create_latex_table(data, caption, label)create_latex_table(data, caption, label)
data |
Data frame. A dataframe-based table |
caption |
String. Table caption |
label |
String. Table label |
A table based in LaTeX.
create_latex_table( data = as.data.frame(head(mtcars, 6)), caption = "My caption", label = "My label" )create_latex_table( data = as.data.frame(head(mtcars, 6)), caption = "My caption", label = "My label" )
Create the rda package for a plot or table
create_rda( object, topic_label, fig_or_table, dat, dir = getwd(), ref_line = "msy", scale_amount = 1, table_df = NULL )create_rda( object, topic_label, fig_or_table, dat, dir = getwd(), ref_line = "msy", scale_amount = 1, table_df = NULL )
object |
Object. Table or plot object |
topic_label |
String. Name of the object |
fig_or_table |
String. Indicates whether the object is a "table" or "figure" Options: "figure" or "table" |
dat |
Data frame. Data which will fill in captions and alternative text for the object |
dir |
Path. Directory to where the rda will be saved Default: the working directory ( |
ref_line |
String. Reference line value Default: "msy" Options: Including, but not limited to: "msy", "target", "unfished" |
scale_amount |
Number. A number describing how much to scale down the quantities shown on the y axis. For example, scale_amount = 100 would scale down a value from 500,000 –> 5,000. This scale will be reflected in the y axis label. Default: 1 |
table_df |
Data frame. The data frame that the table will be made into for purposes of exporting a latex formatted table. |
year |
Number. Assessment year Default: the current year |
An rda package for a plot or table object. Requires an object from the R environment such as a ggplot or flextable object.
export_rda(), extract_caps_alttext()
## Not run: create_rda( object = my_plot, topic_label = "my_plot", fig_or_table = "figure", dat = my_data, dir = "path/to/save" ) ## End(Not run)## Not run: create_rda( object = my_plot, topic_label = "my_plot", fig_or_table = "figure", dat = my_data, dir = "path/to/save" ) ## End(Not run)
Included data set that represents a Report.sso file converted using convert_output(). This example is from the 2022 Petrale sole stock assessment.
example_dataexample_data
A tibble (tbl_df, tbl, data.frame) with 591109 rows and 33 variables:
Standard name for estimate or value name
Actual value of the label
Annual indexing value
Names of fleets or surveys indexed by the data
Native reference to male, female, unknown, or none
Specified areas by the model
Indexing column of data
Value of uncertainty associated with the label column
Uncertainty label or name associated with the label columns
Name of keyword (SS3) or list indexing in the original model output for tracking purposes
Time sometimes referenced in decimals to the year and month
"time" for current time series in model; "fore" representing the projected or forecasted years of the model
Month factor
Season usually associated with year
Subseason when used
Birthseason found in SS3
Initial input value in the model when available associated with the label column
Likelihood value for the data point
Platoon also an SS3 indexing value
Age of fish
Indexing column of data
Indexing column of data
Indexing column of data
Indexing column of data
Indexing column of data
Indexing column of data
Indexing column of data
Indexing column of data
Indexing column of data
Alternative age column
Length bins for composition or other length based data
Indexing column of data
Indexing column of data
Export updated key quantities template
export_kqs(..., dir = getwd())export_kqs(..., dir = getwd())
... |
Key quantities whose values should be added to the exported "key_quantities.csv" |
dir |
String directory to write "key_quantities.csv" to. DEFAULT: getwd() |
Exports a file based on key quantities template, with values added next to the names of the key quantities specified as ellipsis arguments. File is saved as "key_quantities.csv" to the specified directory.
## Not run: export_kqs( F.min, F.max, ) export_kqs( F.min, F.max, dir = fs::path(getwd(), "plots") ) ## End(Not run)## Not run: export_kqs( F.min, F.max, ) export_kqs( F.min, F.max, dir = fs::path(getwd(), "plots") ) ## End(Not run)
Export a figure/table, and its caption and alternative text, to an rda object. Typically used after stockplotr::extract_caps_alttext().
export_rda( object = NULL, caps_alttext = NULL, figures_tables_dir = NULL, topic_label = NULL, fig_or_table = NULL, latex_table = NULL )export_rda( object = NULL, caps_alttext = NULL, figures_tables_dir = NULL, topic_label = NULL, fig_or_table = NULL, latex_table = NULL )
object |
Object. The final figure (ggplot) or table (flextable) object. Default: NULL |
caps_alttext |
Data frame or list. The object containing a figure's caption and alternative text, in a list, or a table's caption, likely generated with stockplotr::extract_caps_alttext(). Default: NULL |
figures_tables_dir |
Path. If the user has already created folders containing figures and tables ("figures" and "tables"), figures_tables_dir represents the location of these folders. Otherwise, these two folders will be created automatically, then used to store the exported rda files. Default: NULL |
topic_label |
String. Figure or table label. These labels are found in the "label" column of the "captions_alt_text.csv" file and are used to link the figure or table with its caption/alt text. Default: NULL |
fig_or_table |
String. Indicates whether the plot is a figure or table. Default: NULL Options: "figure", "table" |
latex_table |
Table object. The object containing a LaTeX-based table. Default: NULL |
An rda file with a figure's ggplot, caption, and alternative text, or a table's gt-based table, caption, and LaTeX-based table.
create_rda(), extract_caps_alttext()
## Not run: export_rda( final = final_table_object, caps_alttext = caps_alttext_object, figures_tables_dir = here::here(), topic_label = "biomass_abundance_catch", fig_or_table = "table", latex_table = "latex_table" ) export_rda( final = final_figure_object, caps_alttext = another_caps_alttext_object, figures_tables_dir = "my_figures_tables_dir", topic_label = "landings", fig_or_table = "figure" ) ## End(Not run)## Not run: export_rda( final = final_table_object, caps_alttext = caps_alttext_object, figures_tables_dir = here::here(), topic_label = "biomass_abundance_catch", fig_or_table = "table", latex_table = "latex_table" ) export_rda( final = final_figure_object, caps_alttext = another_caps_alttext_object, figures_tables_dir = "my_figures_tables_dir", topic_label = "landings", fig_or_table = "figure" ) ## End(Not run)
Extract a figure or table's caption and alternative text for usage when generating a figure or table. Typically used before stockplotr::export_rda().
extract_caps_alttext(topic_label = NULL, fig_or_table = NULL, dir = getwd())extract_caps_alttext(topic_label = NULL, fig_or_table = NULL, dir = getwd())
topic_label |
String. Figure or table label. These labels are found in the "label" column of the "captions_alt_text.csv" file and are used to link the figure or table with its caption/alt text. Default: NULL |
fig_or_table |
String. Indicates whether the plot is a figure or table. Default: NULL |
dir |
Path. The directory containing the "captions_alt_text.csv" file. Default: the working directory ( |
A figure's caption and alternative text, in a list, or a table's caption.
## Not run: extract_caps_alttext( topic_label = "biomass", fig_or_table = "figure", dir = here::here() ) extract_caps_alttext( topic_label = "biomass_abundance_catch", fig_or_table = "table", dir = getwd() ) ## End(Not run)## Not run: extract_caps_alttext( topic_label = "biomass", fig_or_table = "figure", dir = here::here() ) extract_caps_alttext( topic_label = "biomass_abundance_catch", fig_or_table = "table", dir = getwd() ) ## End(Not run)
Semi-automate the extraction of key quantities from model results and time
series data from exported figure/table .rda files for eventual transmittance
to SIS via asar::export_to_sis().
extract_sis_data( sis_data_dir = getwd(), key_quantities_dir = getwd(), figures_tables_dir = getwd() )extract_sis_data( sis_data_dir = getwd(), key_quantities_dir = getwd(), figures_tables_dir = getwd() )
sis_data_dir |
Path. Location to save the sis_assmt_template.csv and sis_ts_template.csv files or, if present, the location of the existing sis_assmt_template.csv file. Default: The working directory. |
key_quantities_dir |
Path. Location of the existing key_quantities.csv file. Default: The working directory. |
figures_tables_dir |
Path. Location of the existing 'figures' and 'tables' directories. Default: The working directory. |
See the "Automating data extraction for SIS" vignette for a detailed overview of the workflow and requirements for this function.
## Not run: extract_sis_data( sis_data_dir = getwd(), key_quantities_dir = "my_dir", figures_tables_dir = "my_other_dir" ) ## End(Not run)## Not run: extract_sis_data( sis_data_dir = getwd(), key_quantities_dir = "my_dir", figures_tables_dir = "my_other_dir" ) ## End(Not run)
Substitute key quantities' values into template
fill_in_kqs(df, ...)fill_in_kqs(df, ...)
df |
Data frame. Dataframe created by importing "key_quantity_template.csv" or "key_quantities.csv", empty or partially-filled templates with key quantity names and other associated information |
... |
Key quantity objects whose values will be added to the output dataframe |
The returned dataframe is input for fill_in_kqs().
Dataframe based on key quantities template that contains newly-added values of key quantities indicated via ellipsis.
## Not run: fill_in_kqs( df = data, F.min, F.max ) ## End(Not run)## Not run: fill_in_kqs( df = data, F.min, F.max ) ## End(Not run)
Filter data for input into aesthetics for ggplot2
filter_data( dat, label_name, module = NULL, era = NULL, geom, group = NULL, facet = NULL, scale_amount = 1, interactive = TRUE )filter_data( dat, label_name, module = NULL, era = NULL, geom, group = NULL, facet = NULL, scale_amount = 1, interactive = TRUE )
dat |
Data frame or list. A tibble or named list of tibbles (input as If inputting a list of tibbles, the first tibble's reference point defined
in |
label_name |
String. Name of the label used to filter the data. |
module |
Character vector. (Optional) Module name found in Default: NULL If the interactive and >1 module_name is found, user will select the
module_name in the console. @seealso |
era |
String. Era of data. Default: "time" Options: "early", "time", "fore" (forecast), or NULL (all data) |
geom |
String. Geom used for the plot. Default: "line". Options: "line", "point", or "area" |
group |
String. Single column that groups the data. Set group = "none" to summarize data over all indexing values. Default: NULL Options: Including, but not limited to: "year", "area", "fleet", "sex", "none", NULL |
facet |
Character vector. Column name or names used for faceting. Default: NULL |
scale_amount |
Number. A number to scale the y-axis values. Default: 1 |
interactive |
Logical. TRUE/FALSE; indicate whether the environment is interactive. Default: |
a data frame that is preformatted for plotting with ggplot2.
## Not run: filter_data(dat, "biomass", "line", group = "fleet") ## End(Not run)## Not run: filter_data(dat, "biomass", "line", group = "fleet") ## End(Not run)
Insert key quantities into the captions and alternative text file
insert_kqs(..., dir = getwd())insert_kqs(..., dir = getwd())
... |
Key quantities whose values should be added to the exported "captions_alt_text.csv" |
dir |
String directory to write "captions_alt_text.csv" to. DEFAULT: getwd() |
Exports a file ("captions_alt_text.csv") containing captions and alternative text for figures and tables, with key quantities inserted into the "captions_alt_text_template.csv" template's placeholders.
## Not run: insert_kqs( F.min, F.max ) ## End(Not run)## Not run: insert_kqs( F.min, F.max ) ## End(Not run)
Rename columns and merge estimate and uncertainty columns for table presentation
merge_error(table_data, id_col_vals, unit_label, uncert_lab)merge_error(table_data, id_col_vals, unit_label, uncert_lab)
table_data |
List of dataframes that will be eventually turned into tables |
id_col_vals |
List. A list of variables identifying grouping of the data and their unique values. |
unit_label |
String. The units of the estimate being presented in the table. |
uncert_lab |
String. Uncertainty label. Typically inherited from another function but is the exact string of the uncertainty in the data (e.g., "sd", "se", "cv", "uncertainty").) |
List of formatted dataframes that contain column names formatted for a table along with a merge of values in the estimate and error columns to reduce redundancy in the table.
Create "at-age" plot
plot_aa( dat, x = "year", y = "age", z = "estimate", label = "Abundance", xlab = "Year", ylab = "Age", facet = NULL, proportional = TRUE, ... )plot_aa( dat, x = "year", y = "age", z = "estimate", label = "Abundance", xlab = "Year", ylab = "Age", facet = NULL, proportional = TRUE, ... )
dat |
Data frame. Filtered data frame from standard output file(s) preformatted for the target label from filter_data |
x |
String. Column name of data used to plot on the x-axis Default: "year" |
y |
String. Column name of data used to plot on the y-axis Default: "age" |
z |
String. Column name of data used to control the size of the bubbles Default: "estimate" |
label |
String. Label for the size of the bubbles Default: "Abundance" |
xlab |
String. X-axis label Default: "Year" |
ylab |
String. Y-axis label Default: "Age" |
facet |
Character vector. Column name or names used for faceting. It is not recommended to include more than one facet due to the complexity of the plot. Default: NULL Options: Including, but not limited to: "sex", "area", "fleet" |
proportional |
Logical. TRUE/FALSE; set size of points relative to z when TRUE, point size are relative to one another while when set to FALSE, point size is relative to z Default: |
... |
Inherited arguments from internal functions from geom_point |
Create a plot of abundance at age for a stock assessment report.
## Not run: plot_aa(dat) ## End(Not run)## Not run: plot_aa(dat) ## End(Not run)
Plot Abundance at Age
plot_abundance_at_age( dat, facet = NULL, unit_label = "fish", scale_amount = 1000, proportional = TRUE, module = NULL, interactive = TRUE, make_rda = FALSE, figures_dir = getwd() )plot_abundance_at_age( dat, facet = NULL, unit_label = "fish", scale_amount = 1000, proportional = TRUE, module = NULL, interactive = TRUE, make_rda = FALSE, figures_dir = getwd() )
dat |
Data frame. A data frame returned from convert_output |
facet |
Character vector. Column name or names used for faceting. Set facet = "none" to summarize the data in a single plot. Default: NULL Options: Including, but not limited to: "year", "area", "fleet", "sex", "none", NULL |
unit_label |
String. Abundance units Default: "fish" |
scale_amount |
Number. A number describing how much to scale down the abundance at age. Please choose a value ranging from 1-1,000,000,000 (one billion) in orders of magnitude (e.g., 1, 10, 100, 1000, etc.). For example, scale_amount = 100 would scale down a value from 500,000 –> 5,000 and would report abundance in hundreds of fish (if "fish" was the unit_label). This scale will be reflected in the legend label if proportional is set to FALSE. Default: 1,000 |
proportional |
Logical. TRUE/FALSE; set size of points relative to z when TRUE, point size are relative to one another while when set to FALSE, point size is relative to z Default: |
module |
(Optional) A string indicating the module_name found in Default: NULL If the interactive and >1 module_name is found, user will select the
module_name in the console. @seealso |
interactive |
A logical value indicating if the environment is interactive. Default: |
make_rda |
Logical. TRUE/FALSE; indicate whether to produce an .rda file containing a list with the figure/table, caption, and alternative text (if figure). If TRUE, the .rda will be exported to the folder indicated in the argument "rda_dir". Default: |
figures_dir |
Path. Folder containing the generated .rda files
("rda_files") that will be created if the argument Default: the working directory ( |
The input is from an assessment model output file
translated to a standardized output (convert_output).
There are options to return a ggplot2 object or export an .rda object
containing associated caption and alternative text for the figure.
A plot showing total abundance (or numbers) at age.
convert_output(), filter_data(), process_data(), plot_aa(), export_kqs(), insert_kqs(), create_rda()
plot_abundance_at_age( dat = stockplotr:::example_data, facet = "growth_pattern", unit_label = "fish", scale_amount = 1000, proportional = TRUE ) plot_abundance_at_age( dat = stockplotr:::example_data, facet = "none", proportional = FALSE )plot_abundance_at_age( dat = stockplotr:::example_data, facet = "growth_pattern", unit_label = "fish", scale_amount = 1000, proportional = TRUE ) plot_abundance_at_age( dat = stockplotr:::example_data, facet = "none", proportional = FALSE )
Plot Total Biomass
plot_biomass( dat, geom = "line", group = NULL, facet = NULL, ref_line = "msy", era = NULL, unit_label = "mt", module = NULL, scale_amount = 1, relative = FALSE, make_rda = FALSE, figures_dir = getwd(), interactive = TRUE, ... )plot_biomass( dat, geom = "line", group = NULL, facet = NULL, ref_line = "msy", era = NULL, unit_label = "mt", module = NULL, scale_amount = 1, relative = FALSE, make_rda = FALSE, figures_dir = getwd(), interactive = TRUE, ... )
dat |
Data frame or list. A tibble or named list of tibbles (input as If inputting a list of tibbles, the first tibble's reference point defined
in |
geom |
String. Geom used for the plot. Default: "line". Options: "line", "point", or "area" |
group |
String. Single column that groups the data. Set group = "none" to summarize data over all indexing values. Default: NULL Options: Including, but not limited to: "year", "area", "fleet", "sex", "none", NULL |
facet |
Character vector. Column name or names used for faceting. Default: NULL |
ref_line |
String. Type of reference point to
compare biomass to. The default Default: "msy" Options: Including, but not limited to: "target", "MSY", "unfished" |
era |
String. Era of data. Default: "time" Options: "early", "time", "fore" (forecast), or NULL (all data) |
unit_label |
String. Biomass units Default: "mt" |
module |
Character vector. (Optional) Module name found in Default: NULL If the interactive and >1 module_name is found, user will select the
module_name in the console. @seealso |
scale_amount |
Number. A number to scale the y-axis values. Default: 1 |
relative |
Logical. TRUE/FALSE; specify whether to set y-axis values relative to the ref_line value. Default: |
make_rda |
Logical. TRUE/FALSE; indicate whether to save the object and
make an automated caption and alternative text in the form of an Default: |
figures_dir |
Path. Path to the "figures" folder. Default: The folder is created within the path if it does not exist. |
interactive |
Logical. TRUE/FALSE; indicate whether the environment is interactive. Default: |
... |
Arguments called from geom_line or geom_point |
The input is from an assessment model output file
translated to a standardized output (convert_output).
There are options to return a ggplot2 object or export an .rda object
containing associated caption and alternative text for the figure.
A plot showing total biomass.
convert_output(), plot_timeseries(), calculate_reference_point(), reference_line(), filter_data(), process_data(), export_kqs(), insert_kqs(), create_rda()
plot_biomass( dat = stockplotr:::example_data, unit_label = "mt", ref_line = c("target" = 20000), scale_amount = 100, module = "TIME_SERIES", figures_dir = getwd() ) plot_biomass( dat = stockplotr:::example_data, ref_line = NULL, module = "TIME_SERIES", figures_dir = getwd() )plot_biomass( dat = stockplotr:::example_data, unit_label = "mt", ref_line = c("target" = 20000), scale_amount = 100, module = "TIME_SERIES", figures_dir = getwd() ) plot_biomass( dat = stockplotr:::example_data, ref_line = NULL, module = "TIME_SERIES", figures_dir = getwd() )
Plot Total Biomass at Age (BAA)
plot_biomass_at_age( dat, facet = NULL, unit_label = "mt", scale_amount = 1000, proportional = TRUE, module = NULL, interactive = TRUE, make_rda = FALSE, figures_dir = getwd() )plot_biomass_at_age( dat, facet = NULL, unit_label = "mt", scale_amount = 1000, proportional = TRUE, module = NULL, interactive = TRUE, make_rda = FALSE, figures_dir = getwd() )
dat |
Data frame. A data frame returned from convert_output |
facet |
Character vector. Column name or names used for faceting. Set facet = "none" to summarize the data in a single plot. Default: NULL Options: Including, but not limited to: "year", "area", "fleet", "sex", "none", NULL |
unit_label |
String. Abundance units Default: "fish" |
scale_amount |
Number. A number describing how much to scale down the biomass at age. For example, scale_amount = 100 would scale down a value from 500,000 –> 5,000. This scale will be reflected in the legend label if proportion is set to FALSE. Default: 1,000 |
proportional |
Logical. TRUE/FALSE; set size of points relative to z when TRUE, point size are relative to one another while when set to FALSE, point size is relative to z Default: |
module |
(Optional) A string indicating the module_name found in Default: NULL If the interactive and >1 module_name is found, user will select the
module_name in the console. @seealso |
interactive |
Logical. TRUE/FALSE; indicate whether the environment in which the function is operating is interactive. This bypasses some options for filtering when preparing data for the plot. Default: |
make_rda |
Logical. TRUE/FALSE; indicate whether to produce an .rda file containing a list with the figure/table, caption, and alternative text (if figure). If TRUE, the .rda will be exported to the folder indicated in the argument "rda_dir". Default: |
figures_dir |
Path. Folder containing the generated .rda files
("rda_files") that will be created if the argument Default: the working directory ( |
The input is from an assessment model output file
translated to a standardized output (convert_output).
There are options to return a ggplot2 object or export an .rda object
containing associated caption and alternative text for the figure.
A plot showing total biomass at age.
convert_output(), filter_data(), process_data(), plot_aa(), export_kqs(), insert_kqs(), create_rda()
plot_biomass_at_age( dat = stockplotr:::example_data, unit_label = "mt", scale_amount = 100, proportional = FALSE, # displays legend make_rda = FALSE ) plot_biomass_at_age( dat = stockplotr:::example_data, unit_label = "mt", facet = "none", proportional = FALSE )plot_biomass_at_age( dat = stockplotr:::example_data, unit_label = "mt", scale_amount = 100, proportional = FALSE, # displays legend make_rda = FALSE ) plot_biomass_at_age( dat = stockplotr:::example_data, unit_label = "mt", facet = "none", proportional = FALSE )
Plot catch-at-age
plot_catch_at_age( dat, facet = NULL, era = "time", unit_label = "mt", scale_amount = 1, proportional = TRUE, interactive = TRUE, module = NULL, make_rda = FALSE, figures_dir = getwd() )plot_catch_at_age( dat, facet = NULL, era = "time", unit_label = "mt", scale_amount = 1, proportional = TRUE, interactive = TRUE, module = NULL, make_rda = FALSE, figures_dir = getwd() )
dat |
Data frame. A data frame returned from convert_output |
facet |
Character vector. Column name or names used for faceting. Set facet = "none" to summarize the data in a single plot. Default: NULL Options: Including, but not limited to: "year", "area", "fleet", "sex", "none", NULL |
era |
String. Era of data. Default: "time" Options: "early", "time", "fore" (forecast), or NULL (all data) |
unit_label |
String. Units of catch used to label the axis Default: "mt" |
scale_amount |
Number. A number describing how much to scale down the catch at age. Please choose a value ranging from 1-1,000,000,000 (one billion) in orders of magnitude (e.g., 1, 10, 100, 1000, etc.). For example, scale_amount = 100 would scale down a value from 500,000 –> 5,000 and would report catch in hundreds of the 'unit_label'. This scale will be reflected in the legend label if proportional is set to FALSE. Default: 1 |
proportional |
Logical. TRUE/FALSE; set size of points relative to z when TRUE, point size are relative to one another while when set to FALSE, point size is relative to z Default: |
interactive |
Logical. TRUE/FALSE; indicate whether the environment is interactive. Default: |
module |
Character vector. (Optional) Module name found in Default: NULL If the interactive and >1 module_name is found, user will select the
module_name in the console. @seealso |
make_rda |
Logical. TRUE/FALSE; indicate whether to produce an .rda file containing a list with the figure/table, caption, and alternative text (if figure). If TRUE, the .rda will be exported to the folder indicated in the argument "rda_dir". Default: |
figures_dir |
Path. Folder containing the generated .rda files
("rda_files") that will be created if the argument Default: the working directory ( |
This plot is made only when catch or landings are explicitly named
in the output file. The current plot function does not combine all sources of
catch.
The input is from an assessment model output file
translated to a standardized output (convert_output).
There are options to return a ggplot2 object or export an .rda object
containing associated caption and alternative text for the figure.
A plot showing catch or landings at age
convert_output(), filter_data(), process_data(), plot_aa(), export_kqs(), insert_kqs(), create_rda()
plot_catch_at_age( dat = stockplotr:::example_data, facet = "fleet", unit_label = "mt", scale_amount = 100, interactive = FALSE, make_rda = FALSE, figures_dir = getwd() ) plot_catch_at_age( dat = stockplotr:::example_data, facet = "none", unit_label = "mt", scale_amount = 100, interactive = FALSE, era = "fore", proportional = FALSE )plot_catch_at_age( dat = stockplotr:::example_data, facet = "fleet", unit_label = "mt", scale_amount = 100, interactive = FALSE, make_rda = FALSE, figures_dir = getwd() ) plot_catch_at_age( dat = stockplotr:::example_data, facet = "none", unit_label = "mt", scale_amount = 100, interactive = FALSE, era = "fore", proportional = FALSE )
Plot discards as a line graph.
plot_discard( dat, group = NULL, facet = NULL, unit_label = "mt", era = NULL, lbs = FALSE, scale_amount = 1, interactive = TRUE, module = NULL, make_rda = FALSE, figures_dir = getwd() )plot_discard( dat, group = NULL, facet = NULL, unit_label = "mt", era = NULL, lbs = FALSE, scale_amount = 1, interactive = TRUE, module = NULL, make_rda = FALSE, figures_dir = getwd() )
dat |
Data frame or list. A tibble or named list of tibbles (input as If inputting a list of tibbles, the first tibble's reference point defined
in |
group |
String. Single column that groups the data. Set group = "none" to summarize data over all indexing values. Default: NULL Options: Including, but not limited to: "year", "area", "fleet", "sex", "none", NULL |
facet |
Character vector. Column name or names used for faceting. Default: NULL |
unit_label |
String. Spawning biomass unit. Default: "mt" |
era |
String. Era of data. Default: "time" Options: "early", "time", "fore" (forecast), or NULL (all data) |
lbs |
Logical. TRUE/FALSE; indicate whether to convert the y-axis values from kilograms to pounds. The default units match the default in the unit_label argument - 'mt'. Default: |
scale_amount |
Number. A number to scale the y-axis values. Default: 1 |
interactive |
Logical. TRUE/FALSE; indicate whether the environment is interactive. Default: |
module |
Character vector. (Optional) Module name found in Default: NULL If the interactive and >1 module_name is found, user will select the
module_name in the console. @seealso |
make_rda |
Logical. TRUE/FALSE; indicate whether to save the object and
make an automated caption and alternative text in the form of an Default: |
figures_dir |
Path. Path to the "figures" folder. Default: The folder is created within the path if it does not exist. |
The input is from an assessment model output file
translated to a standardized output (convert_output).
There are options to return a ggplot2 object or export an .rda object
containing associated caption and alternative text for the figure.
A ggplot showing discards over time, usually by fleet.
All plotting functions automatically recognize indexing variables and will
use them in groupings and/or facetting. @seealso process_data().
convert_output(), plot_timeseries(), calculate_reference_point(), reference_line(), filter_data(), process_data(), export_kqs(), insert_kqs(), create_rda()
plot_discard( dat = stockplotr:::example_data, module = "DISCARD_OUTPUT" )plot_discard( dat = stockplotr:::example_data, module = "DISCARD_OUTPUT" )
Create plot with error
plot_error( dat, x = "year", y = "estimate", geom = "point", group = NULL, facet = NULL, xlab = "Year", ylab = NULL, hline = TRUE, ... )plot_error( dat, x = "year", y = "estimate", geom = "point", group = NULL, facet = NULL, xlab = "Year", ylab = NULL, hline = TRUE, ... )
dat |
Data frame. Filtered data frame from standard output file(s) preformatted for the target label from filter_data |
x |
String. Column name of data used to plot on the x-axis Default: "year" |
y |
String. Column name of data used to plot on the y-axis Default: "estimate" |
geom |
String. Type of geom to use for plotting found in ggplot2 (e.g. "point", "line", etc.). Default: "line" Options: "point" and "area" |
group |
String. Single column that groups the data. Currently can only have one level of grouping. Default: NULL Options: Including, but not limited to: "year", "area", "fleet", "sex", "none", NULL |
facet |
Character vector. Column name or names used for faceting (e.g. "year", "area", etc.) Default: NULL |
xlab |
String. X-axis label Default: "Year" |
ylab |
String. Y-axis label. If NULL, it will be set to the name
of Default: NULL |
hline |
Logical. TRUE/FALSE; indicate whether to place a horizontal line at 1 Default: |
... |
Inherited arguments from internal functions from ggplot2::geom_xx |
The user can create a line, point, or area plot, where the x-axis is year and y can vary for any time series quantity. Currently, grouping is restricted to one group where faceting can be any number of facets.
Create a plot with error for a stock assessment report.
Plot fishing mortality timeseries
plot_fishing_mortality( dat, geom = "line", group = NULL, facet = NULL, ref_line = "msy", era = NULL, module = NULL, make_rda = FALSE, figures_dir = getwd(), interactive = TRUE, ... )plot_fishing_mortality( dat, geom = "line", group = NULL, facet = NULL, ref_line = "msy", era = NULL, module = NULL, make_rda = FALSE, figures_dir = getwd(), interactive = TRUE, ... )
dat |
Data frame or list. A tibble or named list of tibbles (input as If inputting a list of tibbles, the first tibble's reference point defined
in |
geom |
String. Geom used for the plot. Default: "line". Options: "line", "point", or "area" |
group |
String. Single column that groups the data. Set group = "none" to summarize data over all indexing values. Default: NULL Options: Including, but not limited to: "year", "area", "fleet", "sex", "none", NULL |
facet |
Character vector. Column name or names used for faceting. Default: NULL |
ref_line |
String or named vector. Reference point name (and value if custom). When multiple models are being compared, a reference line for each model will appear, if desired. The following options can be used to customize the reference line:
Default: "msy" Options: (including, but not limited to) "target", "msy", and "unfished" If the reference point is not found in the data, set ref_line = c("name" = value). |
era |
String. Era of data. Default: "time" Options: "early", "time", "fore" (forecast), or NULL (all data) |
module |
Character vector. (Optional) Module name found in Default: NULL If the interactive and >1 module_name is found, user will select the
module_name in the console. @seealso |
make_rda |
Logical. TRUE/FALSE; indicate whether to save the object and
make an automated caption and alternative text in the form of an Default: |
figures_dir |
Path. Path to the "figures" folder. Default: The folder is created within the path if it does not exist. |
interactive |
Logical. TRUE/FALSE; indicate whether the environment is interactive. Default: |
... |
Arguments called from geom_line or geom_point |
The input is from an assessment model output file
translated to a standardized output (convert_output).
There are options to return a ggplot2 object or export an .rda object
containing associated caption and alternative text for the figure.
A plot showing fishing mortality over time.
convert_output(), filter_data(), process_data(), plot_timeseries(), reference_line(), export_kqs(), insert_kqs(), create_rda()
plot_fishing_mortality( dat = stockplotr:::example_data, ref_line = c("target" = 0.2), group = "fleet", interactive = FALSE, module = "TIME_SERIES" ) plot_fishing_mortality( dat = stockplotr:::example_data, ref_line = c("target" = 0.2), group = "none", interactive = FALSE, module = "TIME_SERIES" )plot_fishing_mortality( dat = stockplotr:::example_data, ref_line = c("target" = 0.2), group = "fleet", interactive = FALSE, module = "TIME_SERIES" ) plot_fishing_mortality( dat = stockplotr:::example_data, ref_line = c("target" = 0.2), group = "none", interactive = FALSE, module = "TIME_SERIES" )
Plot Index of Abundance
plot_index( dat, unit_label = "", group = NULL, facet = NULL, interactive = TRUE, module = NULL, focus = NULL, make_rda = FALSE, figures_dir = getwd(), ... )plot_index( dat, unit_label = "", group = NULL, facet = NULL, interactive = TRUE, module = NULL, focus = NULL, make_rda = FALSE, figures_dir = getwd(), ... )
dat |
Data frame or list. A tibble or named list of tibbles (input as If inputting a list of tibbles, the first tibble's reference point defined
in |
unit_label |
String. Index of abundance/CPUE units Default: "" |
group |
String. Single column that groups the data. Set group = "none" to summarize data over all indexing values. Default: NULL Options: Including, but not limited to: "year", "area", "fleet", "sex", "none", NULL |
facet |
Character vector. Column name or names used for faceting. "fleet" is always added on to any faceting selections Default: NULL Options: May include, but is not limited to: "fleet", "year", "area", NULL |
interactive |
Logical. TRUE/FALSE; indicate whether the environment is interactive. Default: |
module |
Character vector. (Optional) Module name found in Default: NULL If the interactive and >1 module_name is found, user will select the
module_name in the console. @seealso |
focus |
Character vector. Column name or names used to filter data. (i.e. select names of fleets to zoom into the plot) Default: NULL |
make_rda |
Logical. TRUE/FALSE; indicate whether to save the object and
make an automated caption and alternative text in the form of an Default: |
figures_dir |
Path. Path to the "figures" folder. Default: The folder is created within the path if it does not exist. |
... |
Arguments called from geom_line or geom_point |
The input is from an assessment model output file
translated to a standardized output (convert_output).
There are options to return a ggplot2 object or export an .rda object
containing associated caption and alternative text for the figure.
A plot showing the expected and predicted index.
convert_output(), filter_data(), process_data(), plot_obsvpred(), export_kqs(), insert_kqs(), create_rda()
plot_index( dat = stockplotr::example_data, unit_label = "fish/hr", interactive = FALSE )plot_index( dat = stockplotr::example_data, unit_label = "fish/hr", interactive = FALSE )
Plot observed landings
plot_landings( dat, unit_label = "mt", geom = "line", group = NULL, facet = NULL, lbs = FALSE, era = NULL, scale_amount = 1, module = NULL, interactive = TRUE, make_rda = FALSE, figures_dir = getwd(), ... )plot_landings( dat, unit_label = "mt", geom = "line", group = NULL, facet = NULL, lbs = FALSE, era = NULL, scale_amount = 1, module = NULL, interactive = TRUE, make_rda = FALSE, figures_dir = getwd(), ... )
dat |
Data frame or list. A tibble or named list of tibbles (input as If inputting a list of tibbles, the first tibble's reference point defined
in |
unit_label |
String. Spawning biomass unit. Default: "mt" |
geom |
String. Geom used for the plot. Default: "line". Options: "line", "point", or "area" |
group |
String. Single column that groups the data. Set group = "none" to summarize data over all indexing values. Default: NULL Options: Including, but not limited to: "year", "area", "fleet", "sex", "none", NULL |
facet |
Character vector. Column name or names used for faceting. Default: NULL |
lbs |
Logical. TRUE/FALSE; indicate whether to convert the y-axis values from kilograms to pounds. The default units match the default in the unit_label argument - 'mt'. Default: |
era |
String. Era of data. Default: "time" Options: "early", "time", "fore" (forecast), or NULL (all data) |
scale_amount |
Number. A number to scale the y-axis values. Default: 1 |
module |
Character vector. (Optional) Module name found in Default: NULL If the interactive and >1 module_name is found, user will select the
module_name in the console. @seealso |
interactive |
Logical. TRUE/FALSE; indicate whether the environment is interactive. Default: |
make_rda |
Logical. TRUE/FALSE; indicate whether to save the object and
make an automated caption and alternative text in the form of an Default: |
figures_dir |
Path. Path to the "figures" folder. Default: The folder is created within the path if it does not exist. |
... |
Arguments called from geom_line or geom_point |
The input is from an assessment model output file
translated to a standardized output (convert_output).
There are options to return a ggplot2 object or export an .rda object
containing associated caption and alternative text for the figure.
A plot showing cumulative landings over time.
convert_output(), filter_data(), process_data(), plot_timeseries(), export_kqs(), insert_kqs(), create_rda()
plot_landings( dat = stockplotr:::example_data, unit_label = "metric tons", group = "fleet", interactive = FALSE, make_rda = FALSE ) plot_landings( dat = stockplotr:::example_data, unit_label = "metric tons", facet = "fleet", interactive = FALSE, make_rda = FALSE )plot_landings( dat = stockplotr:::example_data, unit_label = "metric tons", group = "fleet", interactive = FALSE, make_rda = FALSE ) plot_landings( dat = stockplotr:::example_data, unit_label = "metric tons", facet = "fleet", interactive = FALSE, make_rda = FALSE )
Plot natural mortality (M) at age
plot_natural_mortality( dat, group = NULL, facet = NULL, era = NULL, interactive = TRUE, module = NULL, make_rda = FALSE, figures_dir = getwd(), ... )plot_natural_mortality( dat, group = NULL, facet = NULL, era = NULL, interactive = TRUE, module = NULL, make_rda = FALSE, figures_dir = getwd(), ... )
dat |
Data frame or list. A tibble or named list of tibbles (input as If inputting a list of tibbles, the first tibble's reference point defined
in |
group |
String. Single column that groups the data. Set group = "none" to summarize data over all indexing values. Default: NULL Options: Including, but not limited to: "year", "area", "fleet", "sex", "none", NULL |
facet |
Character vector. Column name or names used for faceting. Default: NULL |
era |
String. Era of data. Default: "time" Options: "early", "time", "fore" (forecast), or NULL (all data) |
interactive |
Logical. TRUE/FALSE; indicate whether the environment is interactive. Default: |
module |
Character vector. (Optional) Module name found in Default: NULL If the interactive and >1 module_name is found, user will select the
module_name in the console. @seealso |
make_rda |
Logical. TRUE/FALSE; indicate whether to save the object and
make an automated caption and alternative text in the form of an Default: |
figures_dir |
Path. Path to the "figures" folder. Default: The folder is created within the path if it does not exist. |
... |
Arguments called from geom_line or geom_point |
The input is from an assessment model output file
translated to a standardized output (convert_output).
There are options to return a ggplot2 object or export an .rda object
containing associated caption and alternative text for the figure.
A plot showing natural mortality at age.
convert_output(), filter_data(), process_data(), plot_timeseries(), export_kqs(), insert_kqs(), create_rda()
plot_natural_mortality( dat = stockplotr:::example_data, module = "Natural_Mortality", interactive = FALSE )plot_natural_mortality( dat = stockplotr:::example_data, module = "Natural_Mortality", interactive = FALSE )
Plot observed vs. predicted data
plot_obsvpred( dat, x = "year", y = "estimate", observed_label = "observed", predicted_label = "predicted", geom = "line", xlab = "Year", ylab = NULL, group = NULL, facet = NULL )plot_obsvpred( dat, x = "year", y = "estimate", observed_label = "observed", predicted_label = "predicted", geom = "line", xlab = "Year", ylab = NULL, group = NULL, facet = NULL )
dat |
Data frame. Filtered data frame from standard output file(s) preformatted for the target label from filter_data |
x |
String. Column name of data used to plot on the x-axis Default: "year" |
y |
String. Column name of data used to plot on the y-axis Default: "estimate" |
observed_label |
String. Label used to filter the observed data Default: "observed" |
predicted_label |
String. Label used to filter the predicted data Default: "predicted" |
geom |
String. Type of geom to use for plotting found in ggplot2 (e.g. "point", "line", etc.). Default: "line" Options: "point" and "area" |
xlab |
String. X-axis label Default: "Year" |
ylab |
String. Y-axis label. If NULL, it will be set to the name
of Default: NULL |
group |
String. Single column that groups the data. Currently can only have one level of grouping. Default: NULL Options: Including, but not limited to: "year", "area", "fleet", "sex", "none", NULL |
facet |
Character vector. Column name or names used for faceting (e.g. "year", "area", etc.) Default: NULL |
A plot of observed vs. predicted data for a stock assessment report.
Plot Recruitment
plot_recruitment( dat, unit_label = "mt", scale_amount = 1, era = NULL, group = NULL, facet = NULL, interactive = TRUE, module = NULL, make_rda = FALSE, figures_dir = getwd() )plot_recruitment( dat, unit_label = "mt", scale_amount = 1, era = NULL, group = NULL, facet = NULL, interactive = TRUE, module = NULL, make_rda = FALSE, figures_dir = getwd() )
dat |
Data frame or list. A tibble or named list of tibbles (input as If inputting a list of tibbles, the first tibble's reference point defined
in |
unit_label |
String. Units for recruitment Default: "mt" |
scale_amount |
Number. A number to scale the y-axis values. Default: 1 |
era |
String. Era of data. Default: "time" Options: "early", "time", "fore" (forecast), or NULL (all data) |
group |
String. Single column that groups the data. Set group = "none" to summarize data over all indexing values. Default: NULL Options: Including, but not limited to: "year", "area", "fleet", "sex", "none", NULL |
facet |
Character vector. Column name or names used for faceting. Default: NULL |
interactive |
Logical. TRUE/FALSE; indicate whether the environment is interactive. Default: |
module |
Character vector. (Optional) Module name found in Default: NULL If the interactive and >1 module_name is found, user will select the
module_name in the console. @seealso |
make_rda |
Logical. TRUE/FALSE; indicate whether to save the object and
make an automated caption and alternative text in the form of an Default: |
figures_dir |
Path. Path to the "figures" folder. Default: The folder is created within the path if it does not exist. |
The input is from an assessment model output file
translated to a standardized output (convert_output).
There are options to return a ggplot2 object or export an .rda object
containing associated caption and alternative text for the figure.
A plot showing recruitment over time.
convert_output(), filter_data(), process_data(), plot_timeseries(), export_kqs(), insert_kqs(), create_rda()
plot_recruitment( dat = stockplotr:::example_data, unit_label = "metric tons", scale_amount = 100, interactive = TRUE, module = "TIME_SERIES", make_rda = FALSE ) plot_recruitment( dat = stockplotr:::example_data, era = "fore", module = "TIME_SERIES", make_rda = FALSE )plot_recruitment( dat = stockplotr:::example_data, unit_label = "metric tons", scale_amount = 100, interactive = TRUE, module = "TIME_SERIES", make_rda = FALSE ) plot_recruitment( dat = stockplotr:::example_data, era = "fore", module = "TIME_SERIES", make_rda = FALSE )
Plot recruitment deviations
plot_recruitment_deviations( dat, module = NULL, era = NULL, interactive = TRUE, make_rda = FALSE, figures_dir = getwd(), ... )plot_recruitment_deviations( dat, module = NULL, era = NULL, interactive = TRUE, make_rda = FALSE, figures_dir = getwd(), ... )
dat |
Data frame or list. A tibble or named list of tibbles (input as If inputting a list of tibbles, the first tibble's reference point defined
in |
module |
Character vector. (Optional) Module name found in Default: NULL If the interactive and >1 module_name is found, user will select the
module_name in the console. @seealso |
era |
String. Era of data. Default: "time" Options: "early", "time", "fore" (forecast), or NULL (all data) |
interactive |
Logical. TRUE/FALSE; indicate whether the environment is interactive. Default: |
make_rda |
Logical. TRUE/FALSE; indicate whether to save the object and
make an automated caption and alternative text in the form of an Default: |
figures_dir |
Path. Path to the "figures" folder. Default: The folder is created within the path if it does not exist. |
... |
Arguments called from geom_line or geom_point |
The input is from an assessment model output file
translated to a standardized output (convert_output).
There are options to return a ggplot2 object or export an .rda object
containing associated caption and alternative text for the figure.
A plot showing recruitment deviations relative to one, over time.
All plotting functions automatically recognize indexing variables and will use them in groupings and/or facetting.
convert_output(), plot_error(), filter_data(),
process_data(), export_kqs(), insert_kqs(), create_rda()
plot_recruitment_deviations( dat = stockplotr:::example_data, interactive = FALSE, size = 1.5 ) plot_recruitment_deviations( dat = stockplotr:::example_data, era = "early", interactive = FALSE, shape = 2 )plot_recruitment_deviations( dat = stockplotr:::example_data, interactive = FALSE, size = 1.5 ) plot_recruitment_deviations( dat = stockplotr:::example_data, era = "early", interactive = FALSE, shape = 2 )
Plot selectivity
plot_selectivity( dat, unit_label = "cm", group = NULL, facet = NULL, interactive = TRUE, module = NULL, make_rda = FALSE, figures_dir = getwd(), ... )plot_selectivity( dat, unit_label = "cm", group = NULL, facet = NULL, interactive = TRUE, module = NULL, make_rda = FALSE, figures_dir = getwd(), ... )
dat |
Data frame or list. A tibble or named list of tibbles (input as If inputting a list of tibbles, the first tibble's reference point defined
in |
unit_label |
units for length-based selectivity. Default: "cm" |
group |
String. Single column that groups the data. Set group = "none" to summarize data over all indexing values. Default: NULL Options: Including, but not limited to: "year", "area", "fleet", "sex", "none", NULL |
facet |
Character vector. Column name or names used for faceting. Default: NULL |
interactive |
Logical. TRUE/FALSE; indicate whether the environment is interactive. Default: |
module |
Character vector. (Optional) Module name found in Default: NULL If the interactive and >1 module_name is found, user will select the
module_name in the console. @seealso |
make_rda |
Logical. TRUE/FALSE; indicate whether to save the object and
make an automated caption and alternative text in the form of an Default: |
figures_dir |
Path. Path to the "figures" folder. Default: The folder is created within the path if it does not exist. |
... |
Arguments called from geom_line or geom_point |
The input is from an assessment model output file
translated to a standardized output (convert_output).
There are options to return a ggplot2 object or export an .rda object
containing associated caption and alternative text for the figure.
A plot showing selectivity by age or length.
convert_output(), filter_data(), process_data(), plot_timeseries(), export_kqs(), insert_kqs(), create_rda()
plot_selectivity( dat = stockplotr:::example_data, interactive = TRUE, module = "AGE_SELEX", make_rda = FALSE ) plot_selectivity( dat = stockplotr:::example_data, module = "LEN_SELEX", make_rda = FALSE )plot_selectivity( dat = stockplotr:::example_data, interactive = TRUE, module = "AGE_SELEX", make_rda = FALSE ) plot_selectivity( dat = stockplotr:::example_data, module = "LEN_SELEX", make_rda = FALSE )
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, geom = "line", group = NULL, facet = NULL, ref_line = "msy", unit_label = "mt", era = NULL, lbs = FALSE, module = NULL, scale_amount = 1, relative = FALSE, make_rda = FALSE, figures_dir = getwd(), interactive = TRUE, ... )plot_spawning_biomass( dat, geom = "line", group = NULL, facet = NULL, ref_line = "msy", unit_label = "mt", era = NULL, lbs = FALSE, module = NULL, scale_amount = 1, relative = FALSE, make_rda = FALSE, figures_dir = getwd(), interactive = TRUE, ... )
dat |
Data frame or list. A tibble or named list of tibbles (input as If inputting a list of tibbles, the first tibble's reference point defined
in |
geom |
String. Geom used for the plot. Default: "line". Options: "line", "point", or "area" |
group |
String. Single column that groups the data. Set group = "none" to summarize data over all indexing values. Default: NULL Options: Including, but not limited to: "year", "area", "fleet", "sex", "none", NULL |
facet |
Character vector. Column name or names used for faceting. Default: NULL |
ref_line |
String or named vector. Reference point name (and value if custom). When multiple models are being compared, a reference line for each model will appear, if desired. The following options can be used to customize the reference line:
Default: "msy" Options: (including, but not limited to) "target", "msy", and "unfished" If the reference point is not found in the data, set ref_line = c("name" = value). |
unit_label |
String. Spawning biomass unit. Default: "mt" |
era |
String. Era of data. Default: "time" Options: "early", "time", "fore" (forecast), or NULL (all data) |
lbs |
Logical. TRUE/FALSE; indicate whether to convert the y-axis values from kilograms to pounds. The default units match the default in the unit_label argument - 'mt'. Default: |
module |
Character vector. (Optional) Module name found in Default: NULL If the interactive and >1 module_name is found, user will select the
module_name in the console. @seealso |
scale_amount |
Number. A number to scale the y-axis values. Default: 1 |
relative |
Logical. TRUE/FALSE; specify whether to set y-axis values relative to the ref_line value. Default: |
make_rda |
Logical. TRUE/FALSE; indicate whether to save the object and
make an automated caption and alternative text in the form of an Default: |
figures_dir |
Path. Path to the "figures" folder. Default: The folder is created within the path if it does not exist. |
interactive |
Logical. TRUE/FALSE; indicate whether the environment is interactive. Default: |
... |
Arguments called from geom_line or geom_point |
The input is from an assessment model output file
translated to a standardized output (convert_output).
There are options to return a ggplot2 object or export an .rda object
containing associated caption and alternative text for the figure.
A plot showing spawning biomass over time.
All plotting functions automatically recognize indexing variables and will
use them in groupings and/or facetting. @seealso process_data().
convert_output(), plot_timeseries(), calculate_reference_point(), reference_line(), filter_data(), process_data(), export_kqs(), insert_kqs(), create_rda()
plot_spawning_biomass( dat = stockplotr:::example_data, geom = "line", ref_line = "msy", unit_label = "mt", scale_amount = 1000, interactive = FALSE, module = "TIME_SERIES", linewidth = 1.5 ) plot_spawning_biomass( dat = stockplotr:::example_data, ref_line = c("target" = 10), interactive = FALSE, module = "TIME_SERIES" ) ## Not run: plot_spawning_biomass( dat = list("2023" = model1, "2025" = model2), ref_line = c("SBF30" = 1500, "SBF40" = 2300) ) ## End(Not run)plot_spawning_biomass( dat = stockplotr:::example_data, geom = "line", ref_line = "msy", unit_label = "mt", scale_amount = 1000, interactive = FALSE, module = "TIME_SERIES", linewidth = 1.5 ) plot_spawning_biomass( dat = stockplotr:::example_data, ref_line = c("target" = 10), interactive = FALSE, module = "TIME_SERIES" ) ## Not run: plot_spawning_biomass( dat = list("2023" = model1, "2025" = model2), ref_line = c("SBF30" = 1500, "SBF40" = 2300) ) ## End(Not run)
Plot spawning potential ratio (SPR)
plot_spr( dat, geom = "line", group = NULL, facet = NULL, ref_line = "target", era = "time", module = NULL, interactive = TRUE, make_rda = FALSE, figures_dir = getwd(), ylab = NULL, ... )plot_spr( dat, geom = "line", group = NULL, facet = NULL, ref_line = "target", era = "time", module = NULL, interactive = TRUE, make_rda = FALSE, figures_dir = getwd(), ylab = NULL, ... )
dat |
Data frame or list. A tibble or named list of tibbles (input as If inputting a list of tibbles, the first tibble's reference point defined
in |
geom |
String. Geom used for the plot. Default: "line". Options: "line", "point", or "area" |
group |
String. Single column that groups the data. Set group = "none" to summarize data over all indexing values. Default: NULL Options: Including, but not limited to: "year", "area", "fleet", "sex", "none", NULL |
facet |
Character vector. Column name or names used for faceting. Default: NULL |
ref_line |
String or named vector. Reference point name (and value if custom). When multiple models are being compared, a reference line for each model will appear, if desired. The following options can be used to customize the reference line:
Default: "msy" Options: (including, but not limited to) "target", "msy", and "unfished" If the reference point is not found in the data, set ref_line = c("name" = value). |
era |
String. Era of data. Default: "time" Options: "early", "time", "fore" (forecast), or NULL (all data) |
module |
Character vector. (Optional) Module name found in Default: NULL If the interactive and >1 module_name is found, user will select the
module_name in the console. @seealso |
interactive |
Logical. TRUE/FALSE; indicate whether the environment is interactive. Default: |
make_rda |
Logical. TRUE/FALSE; indicate whether to save the object and
make an automated caption and alternative text in the form of an Default: |
figures_dir |
Path. Path to the "figures" folder. Default: The folder is created within the path if it does not exist. |
ylab |
String. Y-axis label to show. |
... |
Arguments called from geom_line or geom_point |
The input is from an assessment model output file
translated to a standardized output (convert_output).
There are options to return a ggplot2 object or export an .rda object
containing associated caption and alternative text for the figure.
A plot showing spawning potential ratio (SPR).
convert_output(), filter_data(), process_data(), plot_timeseries(), export_kqs(), insert_kqs(), create_rda()
plot_spr( dat = stockplotr:::example_data, unit_label = "metric tons", group = NULL, interactive = FALSE, make_rda = FALSE, ylab = "SPR" ) plot_spr( dat = stockplotr:::example_data, unit_label = "metric tons", facet = NULL, module = "DERIVED_QUANTITIES", interactive = FALSE, make_rda = FALSE, ylab = "(1-SPR)/(1-SPR_ref)" )plot_spr( dat = stockplotr:::example_data, unit_label = "metric tons", group = NULL, interactive = FALSE, make_rda = FALSE, ylab = "SPR" ) plot_spr( dat = stockplotr:::example_data, unit_label = "metric tons", facet = NULL, module = "DERIVED_QUANTITIES", interactive = FALSE, make_rda = FALSE, ylab = "(1-SPR)/(1-SPR_ref)" )
Plot Stock Recruit Relationship
plot_stock_recruitment( dat, spawning_biomass_label = "mt", recruitment_label = "mt", interactive = TRUE, era = NULL, module = NULL, scale_amount = 1, make_rda = FALSE, figures_dir = getwd() )plot_stock_recruitment( dat, spawning_biomass_label = "mt", recruitment_label = "mt", interactive = TRUE, era = NULL, module = NULL, scale_amount = 1, make_rda = FALSE, figures_dir = getwd() )
dat |
Data frame or list. A tibble or named list of tibbles (input as If inputting a list of tibbles, the first tibble's reference point defined
in |
spawning_biomass_label |
String. Units for spawning biomass Default: "mt" |
recruitment_label |
String. Units for recruitment Default: "mt" |
interactive |
Logical. TRUE/FALSE; indicate whether the environment the plot is being made in is interactive. By default, this is set to false. If true, dependent on your data, a option menu will pop-up. Default: TRUE |
era |
String. Era of data. Default: "time" Options: "early", "time", "fore" (forecast), or NULL (all data) |
module |
Character vector. (Optional) Module name found in Default: NULL If the interactive and >1 module_name is found, user will select the
module_name in the console. @seealso |
scale_amount |
Number. A number to scale the y-axis values. Default: 1 |
make_rda |
Logical. TRUE/FALSE; indicate whether to save the object and
make an automated caption and alternative text in the form of an Default: |
figures_dir |
Path. Path to the "figures" folder. Default: The folder is created within the path if it does not exist. |
The input is from an assessment model output file
translated to a standardized output (convert_output).
There are options to return a ggplot2 object or export an .rda object
containing associated caption and alternative text for the figure.
A plot showing the stock recruitment relationship.
convert_output(), filter_data(), process_data(), plot_timeseries(), export_kqs(), insert_kqs(), create_rda()
plot_stock_recruitment( dat = stockplotr:::example_data, interactive = FALSE, spawning_biomass_label = "metric tons", recruitment_label = "metric tons", module = "DERIVED_QUANTITIES" )plot_stock_recruitment( dat = stockplotr:::example_data, interactive = FALSE, spawning_biomass_label = "metric tons", recruitment_label = "metric tons", module = "DERIVED_QUANTITIES" )
Plot time series trends
plot_timeseries( dat, x = "year", y = "estimate", geom = "line", xlab = "Year", ylab = NULL, group = NULL, facet = NULL, ... )plot_timeseries( dat, x = "year", y = "estimate", geom = "line", xlab = "Year", ylab = NULL, group = NULL, facet = NULL, ... )
dat |
Data frame. Filtered data frame from standard output file(s) preformatted for the target label from filter_data |
x |
String. Column name of data used to plot on the x-axis Default: "year" |
y |
String. Column name of data used to plot on the y-axis Default: "estimate" |
geom |
String. Type of geom to use for plotting found in ggplot2 (e.g. "point", "line", etc.). Default: "line" Options: "point" and "area" |
xlab |
String. X-axis label Default: "Year" |
ylab |
String. Y-axis label. If NULL, it will be set to the name
of Default: NULL |
group |
String. Single column that groups the data. Currently can only have one level of grouping. Default: NULL Options: Including, but not limited to: "year", "area", "fleet", "sex", "none", NULL |
facet |
Character vector. Column name or names used for faceting (e.g. "year", "area", etc.) Default: NULL |
... |
Inherited arguments from internal functions from ggplot2::geom_xx |
The user can create a line, point, or area plot, where the x-axis is year and y can vary for any time series quantity. Currently, grouping is restricted to one group where faceting can be any number of facets.
Create a time series plot for a stock assessment report.
## Not run: plot_timeseries(dat, x = "year", y = "estimate", geom = "line", xlab = "Year", ylab = "Biomass", group = "fleet", facet = "area" ) ## End(Not run)## Not run: plot_timeseries(dat, x = "year", y = "estimate", geom = "line", xlab = "Year", ylab = "Biomass", group = "fleet", facet = "area" ) ## End(Not run)
Standardized output of the 2018 Gulf of Alaska Pollock stock assessment produced from Rceattle including all of the values needed to create plots and tables in stockplotr. The example can be found and run from the Rceattle repository.
data(pollock)data(pollock)
A tibble (tbl_df, tbl, data.frame) with 9,983 rows and 35 variables:
Standard name for estimate or value name
Actual value of the label
Annual indexing value
Names of fleets or surveys indexed by the data
Native reference to male, female, unknown, or none
Specified areas by the model
Indexing column of data
Value of uncertainty associated with the label column
Uncertainty label or name associated with the label columns
Name of keyword (SS3) or list indexing in the original model output for tracking purposes
Time sometimes referenced in decimals to the year and month
"time" for current time series in model; "fore" representing the projected or forecasted years of the model
Month factor
Season usually associated with year
Subseason when used
Birthseason found in SS3
Initial input value in the model when available associated with the label column
Likelihood value for the data point
Platoon also an SS3 indexing value
Age of fish
Indexing column of data
Indexing column of data
Indexing column of data
Indexing column of data
Indexing column of data
Indexing column of data
Indexing column of data
Indexing column of data
Indexing column of data
Alternative age column
Length bins for composition or other length based data
Indexing column of data
Indexing column of data
Adams, G. D., Holsman, K. K., Barbeaux, S. J., Dorn, M. W., Ianelli, J. N., Spies, I., … Punt, A. E. (2022) (
data(pollock) head(pollock) unique(pollock$label)data(pollock) head(pollock) unique(pollock$label)
Processing for figures
process_data(dat, group = NULL, facet = NULL, lbs = FALSE)process_data(dat, group = NULL, facet = NULL, lbs = FALSE)
dat |
Data frame. Pre-filtered data from filter_data following a long format data. |
group |
String. Indexing variable of the data. To remove any groups and summarize data across all factors, set group = "none". Setting group = NULL will keep any grouping variables identified in the data by the function. Default: NULL Options: Including, but not limited to: "year", "area", "fleet", "sex", "none", NULL |
facet |
Character vector. Faceting variable(s) of the data. Default: NULL |
lbs |
Logical. TRUE/FALSE; indicate whether to convert the y-axis values from kilograms to pounds. The default units match the default in the unit_label argument - 'metric tons'. Default: |
Automatically detects potential grouping and faceting data from a dataframe output from filter_data.
List of 3 objects:
data |
A data frame of the processed data ready for plotting. |
group |
Grouping variable of the data. If NULL, no grouping variable is identified. If not NULL, the function will verify that the data is indexed by this variables, otherwise it will overwrite it to a different, valid indexed variable or NULL. |
facet |
Faceting variable(s) identifying the variable(s) of the data. If NULL, no faceting variable is identified. Any identified indexed variables found in this function will be added to facet. |
{ filtered <- stockplotr::filter_data( dat = stockplotr:::example_data, label_name = "fishing_mortality$", geom = "line", module = "TIME_SERIES" ) process_data(dat = filtered) }{ filtered <- stockplotr::filter_data( dat = stockplotr:::example_data, label_name = "fishing_mortality$", geom = "line", module = "TIME_SERIES" ) process_data(dat = filtered) }
Processing for tables
process_table(dat, group = NULL, method = "sum", label = NULL, digits = 2)process_table(dat, group = NULL, method = "sum", label = NULL, digits = 2)
dat |
Data frame. Pre-filtered data from filter_data following a long format data. |
group |
String. Indexing variable of the data. To remove any groups and summarize data across all factors, set group = "none". Setting group = NULL will keep any grouping variables identified in the data by the function. Default: NULL Options: Including, but not limited to: "year", "area", "fleet", "sex", "none", NULL |
method |
String. Method for summarizing data when group is set to "none". Default: "sum" Options: "sum" or "mean" |
label |
String. Label value or values used to filter the data. Default: NULL |
digits |
Number. Numeric value indicating the number of rounding digits. Default: 2 |
Input is an object created with filter_data.
A dataframe of processed data ready for formatting into a table.
{ filtered <- filter_data( dat = stockplotr:::example_data, label = "landings", geom = "line", era = "time" ) process_table(dat = filtered, method = "sum") }{ filtered <- filter_data( dat = stockplotr:::example_data, label = "landings", geom = "line", era = "time" ) process_table(dat = filtered, method = "sum") }
Preformatted reference line
reference_line( label_name, ref_line, scale_amount = 1, model_name = "1", direction = "h" )reference_line( label_name, ref_line, scale_amount = 1, model_name = "1", direction = "h" )
label_name |
String. Name of the quantity that users want to extract the reference point from |
ref_line |
String. Reference point(s) |
scale_amount |
Number. A number to scale the y-axis values. Default: 1 |
model_name |
String. Name of the model that will be present in the legend. |
direction |
String. Direction of reference line (either 'h' for horizontal or 'v' for vertical) Options: Including, but not limited to: "msy", "unfished", "target" |
A ggplot2 geom_hline object for a reference point that can be added to a plot
## Not run: reference_line(dat, "biomass", "msy") ## End(Not run)## Not run: reference_line(dat, "biomass", "msy") ## End(Not run)
Export all figures and tables to Rda files within one function. This primary purpose of this function is to quickly export all available figures and tables. We recommend running individual plotting functions for greater customization of figures and tables.
save_all_plots( dat, interactive = FALSE, figures_tables_dir = getwd(), plot_recruitment_options = list(module = "TIME_SERIES"), plot_natural_mortality_options = list(module = "Natural_Mortality"), table_total_catch_options = list(module = "TIME_SERIES"), ... )save_all_plots( dat, interactive = FALSE, figures_tables_dir = getwd(), plot_recruitment_options = list(module = "TIME_SERIES"), plot_natural_mortality_options = list(module = "Natural_Mortality"), table_total_catch_options = list(module = "TIME_SERIES"), ... )
dat |
Data frame or list. A tibble or named list of tibbles (input as If inputting a list of tibbles, the first tibble's reference point defined
in |
interactive |
Logical. TRUE/FALSE; indicate whether the environment is interactive. Default: |
plot_recruitment_options |
List. List object of parameter values to pass
directly to the Default: list(module = "TIME_SERIES") |
plot_natural_mortality_options |
List. List object of parameter values to pass
directly to the Default: list(module = "Natural_Mortality") |
table_total_catch_options |
List. List object of parameter values to pass
directly to the Default: list(module = "TIME_SERIES") ... Additional list objects of parameter values to pass directly to corresponding
plot or table functions. Parameter names should follow the naming convention
|
... |
Arguments called from geom_line or geom_point |
The input is from an assessment model output file translated to a standardized output (convert_output).
Rda files for each figure/table.
convert_output(), create_rda()
## Not run: save_all_plots( dat = example_data, plot_spawning_biomass_options = list( ref_line = "unfished" ), plot_abundance_at_age_options = list( scale_amount = 1, proportional = FALSE ) ) ## End(Not run) ## Not run: save_all_plots( dat = example_data, figures_tables_dir = fs::path("outputs/figures"), plot_recruitment_options = list( module = "TIME_SERIES", unit_label = "Millions of Recruits" # customize unit label for recruitment plot ), plot_spawning_biomass_options = list( ref_line = "unfished" # customize reference line for spawning biomass plot ), plot_abundance_at_age_options = list( scale_amount = 1, # custom scale for abundance-at-age plot proportional = FALSE # don't proportionalize abundance-at-age ), plot_spr_options = list( ylab = "Fishing Intensity (1-SPR)/(1-SPR_ref)" # custom Y label for SPR plot ), plot_fishing_mortality_options = list( facet = "fleet", # facet fishing mortality plot by "fleet" group = "fleet" # group fishing mortality plot by "fleet" ) ) ## End(Not run)## Not run: save_all_plots( dat = example_data, plot_spawning_biomass_options = list( ref_line = "unfished" ), plot_abundance_at_age_options = list( scale_amount = 1, proportional = FALSE ) ) ## End(Not run) ## Not run: save_all_plots( dat = example_data, figures_tables_dir = fs::path("outputs/figures"), plot_recruitment_options = list( module = "TIME_SERIES", unit_label = "Millions of Recruits" # customize unit label for recruitment plot ), plot_spawning_biomass_options = list( ref_line = "unfished" # customize reference line for spawning biomass plot ), plot_abundance_at_age_options = list( scale_amount = 1, # custom scale for abundance-at-age plot proportional = FALSE # don't proportionalize abundance-at-age ), plot_spr_options = list( ylab = "Fishing Intensity (1-SPR)/(1-SPR_ref)" # custom Y label for SPR plot ), plot_fishing_mortality_options = list( facet = "fleet", # facet fishing mortality plot by "fleet" group = "fleet" # group fishing mortality plot by "fleet" ) ) ## End(Not run)
Standardized output of a generic simple example of SS3 found from the r4ss
repository examples. The raw output is converted to an R readable object
using r4ss::ss_output then standardized using stockplotr::convert_output().
data(ss3_simple)data(ss3_simple)
A tibble (tbl_df, tbl, data.frame) with 38,195 rows and 35 variables:
Standard name for estimate or value name
Actual value of the label
Annual indexing value
Names of fleets or surveys indexed by the data
Native reference to male, female, unknown, or none
Specified areas by the model
Indexing column of data
Value of uncertainty associated with the label column
Uncertainty label or name associated with the label columns
Name of keyword (SS3) or list indexing in the original model output for tracking purposes
Time sometimes referenced in decimals to the year and month
"time" for current time series in model; "fore" representing the projected or forecasted years of the model
Month factor
Season usually associated with year
Subseason when used
Birthseason found in SS3
Initial input value in the model when available associated with the label column
Likelihood value for the data point
Platoon also an SS3 indexing value
Age of fish
Indexing column of data
Indexing column of data
Indexing column of data
Indexing column of data
Indexing column of data
Indexing column of data
Indexing column of data
Indexing column of data
Indexing column of data
Alternative age column
Length bins for composition or other length based data
Indexing column of data
Indexing column of data
data(ss3_simple) head(ss3_simple) unique(ss3_simple$label)data(ss3_simple) head(ss3_simple) unique(ss3_simple$label)
Biomass, abundance, and catch time series table
table_biomass_abundance_catch( dat, unit_label = c(biomass = "mt", abundance = "fish", catch = "mt"), era = NULL, interactive = TRUE, group = NULL, method = "sum", module = NULL, label = NULL, make_rda = FALSE, tables_dir = getwd() )table_biomass_abundance_catch( dat, unit_label = c(biomass = "mt", abundance = "fish", catch = "mt"), era = NULL, interactive = TRUE, group = NULL, method = "sum", module = NULL, label = NULL, make_rda = FALSE, tables_dir = getwd() )
dat |
Data frame or list. A tibble or named list of tibbles (input as If inputting a list of tibbles, the first tibble's reference point defined
in |
unit_label |
Character vector. Abbreviated unit label for each quantity Default: c("biomass" = "mt", "abundance" = "fish", "catch" = "mt") |
era |
String. Era of data. Default: "time" Options: "early", "time", "fore" (forecast), or NULL (all data) |
interactive |
Logical. TRUE/FALSE; indicate whether the environment is interactive. Default: |
group |
A string of a single column that groups the data. Set group = "none" to summarize data over all indexing values. Default: NULL Options: Including, but not limited to: "year", "area", "fleet", "sex", "none", NULL |
method |
A string describing the method of summarizing data when group is set to "none". Default: "sum" Options: "sum" or "mean" |
module |
Character vector. (Optional) Module name found in Default: NULL If the interactive and >1 module_name is found, user will select the
module_name in the console. @seealso |
label |
The label that will be chosen from the input file. If unspecified, the function will search the "label" column and use the first matching label in this ordered list: "landings_weight", "landings_numbers", "landings_expected", "landings_predicted", "landings". Default: NULL |
make_rda |
Logical. TRUE/FALSE; indicate whether to save the object and
make an automated caption and alternative text in the form of an Default: |
tables_dir |
The location of the folder containing the table
rda files ("tables") that will be created if the argument |
There are
options to return a gt::gt() object or export an rda object containing
a gt-based table, caption, and LaTeX-based table.
A table of biomass, abundance, catch, and spawning biomass.
convert_output(), filter_data(), process_table(), export_kqs(), insert_kqs(), create_rda()
table_biomass_abundance_catch(stockplotr::example_data) table_biomass_abundance_catch(stockplotr::example_data, unit_label = c("biomass" = "kg", "abundance" = "eggs", "catch" = "kg"), module = c("TIME_SERIES", "CATCH", "TIME_SERIES"), interactive = FALSE )table_biomass_abundance_catch(stockplotr::example_data) table_biomass_abundance_catch(stockplotr::example_data, unit_label = c("biomass" = "kg", "abundance" = "eggs", "catch" = "kg"), module = c("TIME_SERIES", "CATCH", "TIME_SERIES"), interactive = FALSE )
Index of abundance table
table_index( dat, era = NULL, interactive = TRUE, group = NULL, method = "sum", module = NULL, label = NULL, digits = 2, make_rda = FALSE, tables_dir = getwd() )table_index( dat, era = NULL, interactive = TRUE, group = NULL, method = "sum", module = NULL, label = NULL, digits = 2, make_rda = FALSE, tables_dir = getwd() )
dat |
Data frame or list. A tibble or named list of tibbles (input as If inputting a list of tibbles, the first tibble's reference point defined
in |
era |
String. Era of data. Default: "time" Options: "early", "time", "fore" (forecast), or NULL (all data) |
interactive |
Logical. TRUE/FALSE; indicate whether the environment is interactive. Default: |
group |
String. Single column that groups the data. Set group = "none" to summarize data over all indexing values. Default: NULL Options: Including, but not limited to: "year", "area", "fleet", "sex", "none", NULL |
method |
String. Method for summarizing data when group is set to "none". Default: "sum" Options: "sum" or "mean" |
module |
Character vector. (Optional) Module name found in Default: NULL If the interactive and >1 module_name is found, user will select the
module_name in the console. @seealso |
label |
String. The label that will be chosen from the input file. If unspecified, the function will search the "label" column and use the first matching label in this ordered list: "index_weight", "index_numbers", "index_expected", "index_predicted", "index". Default: NULL |
digits |
Number. Numeric value indicating the number of digits values in the table will be rounded to. Default: 2 |
make_rda |
Logical. TRUE/FALSE; indicate whether to save the object and
make an automated caption and alternative text in the form of an Default: |
tables_dir |
Path. The location of the folder containing the generated table
rda files ("tables") that will be created if the argument Default: the working directory ( |
The input is from an assessment model output file
translated to a standardized output (convert_output).
There are options to return a gt::gt() object or export an rda object
containing a gt-based table, caption, and LaTeX-based table.
A table of observed annual index of abundance plus error, stratified by fleet.
convert_output(), filter_data(), process_table(), export_kqs(), insert_kqs(), create_rda()
## Not run: table_index(dat) table_index( dat, make_rda = TRUE, tables_dir = getwd() ) ## End(Not run)## Not run: table_index(dat) table_index( dat, make_rda = TRUE, tables_dir = getwd() ) ## End(Not run)
Landed catch by fleet and year table
table_landings( dat, unit_label = "mt", era = NULL, interactive = TRUE, group = NULL, method = "sum", module = NULL, label = NULL, digits = 2, scale_amount = 1, make_rda = FALSE, tables_dir = getwd() )table_landings( dat, unit_label = "mt", era = NULL, interactive = TRUE, group = NULL, method = "sum", module = NULL, label = NULL, digits = 2, scale_amount = 1, make_rda = FALSE, tables_dir = getwd() )
dat |
Data frame or list. A tibble or named list of tibbles (input as If inputting a list of tibbles, the first tibble's reference point defined
in |
unit_label |
String. Abbreviated landings units Default: "mt" |
era |
String. Era of data. Default: "time" Options: "early", "time", "fore" (forecast), or NULL (all data) |
interactive |
Logical. TRUE/FALSE; indicate whether the environment is interactive. Default: |
group |
String. Single column that groups the data. Set group = "none" to summarize data over all indexing values. Default: NULL Options: Including, but not limited to: "year", "area", "fleet", "sex", "none", NULL |
method |
String. Method for summarizing data when group is set to "none". Default: "sum" Options: "sum" or "mean" |
module |
Character vector. (Optional) Module name found in Default: NULL If the interactive and >1 module_name is found, user will select the
module_name in the console. @seealso |
label |
String. The label that will be chosen from the input file. If unspecified, the function will search the "label" column and use the first matching label in this ordered list: "landings_weight", "landings_numbers", "landings_expected", "landings_predicted", "landings". Default: NULL |
digits |
Number. Numeric value indicating the number of digits values in the table will be rounded to. Default: 2 |
scale_amount |
Number. A number to scale the y-axis values. Default: 1 |
make_rda |
Logical. TRUE/FALSE; indicate whether to save the object and
make an automated caption and alternative text in the form of an Default: |
tables_dir |
Path. The location of the folder containing the generated table
rda files ("tables") that will be created if the argument Default: the working directory ( |
The input is from an assessment model output file
translated to a standardized output (convert_output).
There are options to return a gt::gt() object or export an rda object
containing a gt-based table, caption, and LaTeX-based table.
A table ready of landed catch by fleet and year.
convert_output(), filter_data(), process_table(), export_kqs(), insert_kqs(), create_rda()
table_landings(stockplotr::example_data) table_landings( stockplotr::example_data, unit_label = "landings label", group = "fleet" )table_landings(stockplotr::example_data) table_landings( stockplotr::example_data, unit_label = "landings label", group = "fleet" )
Generates a table showing assumed and projected years of Catch, SB, and F.
table_projections( dat, unit_label = c(catch = "mt", spawning_biomass = "mt", fishing_mortality = ""), interactive = TRUE, module = NULL, make_rda = FALSE, tables_dir = getwd() )table_projections( dat, unit_label = c(catch = "mt", spawning_biomass = "mt", fishing_mortality = ""), interactive = TRUE, module = NULL, make_rda = FALSE, tables_dir = getwd() )
dat |
Data frame or list. A tibble or named list of tibbles (input as If inputting a list of tibbles, the first tibble's reference point defined
in |
unit_label |
Character vector. Abbreviated unit label for each quantity Default: c("catch" = "mt", "spawning_biomass" = "mt", "fishing_mortality" = "") |
interactive |
Logical. TRUE/FALSE; indicate whether the environment is interactive. Default: |
module |
Character vector. (Optional) Module name found in Default: NULL If the interactive and >1 module_name is found, user will select the
module_name in the console. @seealso |
make_rda |
Logical. TRUE/FALSE; indicate whether to save the object and
make an automated caption and alternative text in the form of an Default: |
tables_dir |
Path. The location of the folder containing the generated table
rda files ("tables") that will be created if the argument Default: the working directory ( |
We would like to thank Dan Hennen for sharing his projections table function code, which served as the foundation for this function.
A formatted gt table object.
table_projections( dat = stockplotr::example_data, interactive = FALSE, module = "DERIVED_QUANTITIES" )table_projections( dat = stockplotr::example_data, interactive = FALSE, module = "DERIVED_QUANTITIES" )
Catch (table) by fleet, gear type, sector
table_total_catch( dat, unit_label = "mt", era = NULL, interactive = TRUE, module = NULL, scale_amount = 1, digits = 2, make_rda = FALSE, tables_dir = getwd() )table_total_catch( dat, unit_label = "mt", era = NULL, interactive = TRUE, module = NULL, scale_amount = 1, digits = 2, make_rda = FALSE, tables_dir = getwd() )
dat |
Data frame or list. A tibble or named list of tibbles (input as If inputting a list of tibbles, the first tibble's reference point defined
in |
unit_label |
String. Abbreviated catch units Default: "mt" |
era |
String. Era of data. Default: "time" Options: "early", "time", "fore" (forecast), or NULL (all data) |
interactive |
Logical. TRUE/FALSE; indicate whether the environment is interactive. Default: |
module |
Character vector. (Optional) Module name found in Default: NULL If the interactive and >1 module_name is found, user will select the
module_name in the console. @seealso |
scale_amount |
Number. A number to scale the y-axis values. Default: 1 |
digits |
Number. Numeric value indicating the number of digits catch values in the table will be rounded to. Default: 2 |
make_rda |
Logical. TRUE/FALSE; indicate whether to save the object and
make an automated caption and alternative text in the form of an Default: |
tables_dir |
Path. The location of the folder containing the generated table
rda files ("tables") that will be created if the argument Default: the working directory ( |
The input is from an assessment model output file
translated to a standardized output (convert_output).
There are options to return a gt::gt() object or export an rda object
containing a gt-based table, caption, and LaTeX-based table.
A table ready of landed catch by fleet and year.
convert_output(), filter_data(), process_table(), export_kqs(), insert_kqs(), create_rda()
table_total_catch(stockplotr::example_data, module = "TIME_SERIES" ) table_total_catch( stockplotr::example_data, unit_label = "lbs", module = "TIME_SERIES", digits = 4, scale_amount = 100 )table_total_catch(stockplotr::example_data, module = "TIME_SERIES" ) table_total_catch( stockplotr::example_data, unit_label = "lbs", module = "TIME_SERIES", digits = 4, scale_amount = 100 )
The palette is from the 'viridis' package, which contains palettes distinguishable by those with color vision deficiency.
theme_noaa(discrete = TRUE, ...)theme_noaa(discrete = TRUE, ...)
discrete |
Logical. TRUE/FALSE; indicate whether the color or fill aesthetic is discrete. Default: TRUE |
... |
Arguments passed to |
A list applying a theme to a ggplot2 object.
ggplot2::ggplot( data = OrchardSprays, ggplot2::aes( x = rowpos, y = decrease, color = treatment ) ) + ggplot2::geom_point() + theme_noaa() ggplot2::ggplot( data = OrchardSprays, ggplot2::aes( x = rowpos, y = decrease, color = decrease ) ) + ggplot2::geom_point() + theme_noaa(discrete = FALSE) ## Not run: ggplot2::theme_set(stockplotr::theme_noaa()) ## End(Not run)ggplot2::ggplot( data = OrchardSprays, ggplot2::aes( x = rowpos, y = decrease, color = treatment ) ) + ggplot2::geom_point() + theme_noaa() ggplot2::ggplot( data = OrchardSprays, ggplot2::aes( x = rowpos, y = decrease, color = decrease ) ) + ggplot2::geom_point() + theme_noaa(discrete = FALSE) ## Not run: ggplot2::theme_set(stockplotr::theme_noaa()) ## End(Not run)
Add NOAA formatting to a table
theme_table(x)theme_table(x)
x |
Object. Table from gt, flextable, or kableExtra |
Currently, the function can format table objects from: flextable (flextable package, when installed), gt (gt), and kableExtra (kableExtra).
Add the standard formatting for stock assessment reports for any table.
theme_table(cars |> gt::gt()) theme_table(cars |> kableExtra::kable())theme_table(cars |> gt::gt()) theme_table(cars |> kableExtra::kable())
Standardized output of the 2018 South Atlantic Vermilion Snapper stock assessment produced from the Beaufort Assessment Model (BAM).
data(vermilion_snapper)data(vermilion_snapper)
A tibble (tbl_df, tbl, data.frame) with 35,881 rows and 35 variables:
Standard name for estimate or value name
Actual value of the label
Annual indexing value
Names of fleets or surveys indexed by the data
Native reference to male, female, unknown, or none
Specified areas by the model
Indexing column of data
Value of uncertainty associated with the label column
Uncertainty label or name associated with the label columns
Name of keyword (SS3) or list indexing in the original model output for tracking purposes
Time sometimes referenced in decimals to the year and month
"time" for current time series in model; "fore" representing the projected or forecasted years of the model
Month factor
Season usually associated with year
Subseason when used
Birthseason found in SS3
Initial input value in the model when available associated with the label column
Likelihood value for the data point
Platoon also an SS3 indexing value
Age of fish
Indexing column of data
Indexing column of data
Indexing column of data
Indexing column of data
Indexing column of data
Indexing column of data
Indexing column of data
Indexing column of data
Indexing column of data
Alternative age column
Length bins for composition or other length based data
Indexing column of data
Indexing column of data
data(vermilion_snapper) head(vermilion_snapper) unique(vermilion_snapper$label)data(vermilion_snapper) head(vermilion_snapper) unique(vermilion_snapper$label)