Plot Recruitment

plot_recruitment(
  dat,
  unit_label = "mt",
  scale_amount = 1,
  era = "time",
  group = NULL,
  facet = NULL,
  interactive = TRUE,
  module = NULL,
  make_rda = FALSE,
  figures_dir = getwd()
)

Arguments

dat

A data frame or names list of data frames (input as `list()`) returned from convert_output. The first data frame in the list is used in calculation of a reference line if one is present

unit_label

units for recruitment

scale_amount

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.

era

a string naming the era of data such as historical ("early"), current ("time"), or projected ("fore") data if filtering should occur. Default is set to "time" which is the current time. To plot all data, set era to NULL.

group

a string of a single column that groups the data (e.g. "fleet", "sex", "area", etc.). Currently can only have one level of grouping. If you want to just summarize the data across all factors, set group = "none". In the case there is only one unique value of the grouping and/or NA is available, the function will default to the NAs and in some cases the grouping when there is not an equal number of rows for NA and the grouped data.

facet

a string or vector of strings of a column that facets the data (e.g. "year", "area", etc.)

interactive

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 is FALSE.

module

(Optional) A string indicating the linked module_name associated with the label for the plot if known. Default is NULL. By default, the function will select the most relevant module if more than 1 exists.

make_rda

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 "figures_dir". Default is FALSE.

figures_dir

The location of the folder containing the generated figure rda files ("figures") that will be created if the argument `make_rda` = TRUE. Default is the working directory.

Value

Plot recruitment over time from an assessment model output file translated to a standardized output (convert_output). There are options to return a [ggplot2::ggplot()] object or export an rda object containing associated caption and alternative text for the figure.

Examples

plot_recruitment(
  dat = stockplotr:::example_data,
  unit_label = "metric tons",
  scale_amount = 100,
  interactive = TRUE,
  module = "TIME_SERIES",
  make_rda = FALSE
)
#> Ignoring unknown labels:
#>  colour : "Model"

plot_recruitment(
 dat = stockplotr:::example_data,
 era = "fore",
 module = "TIME_SERIES",
 make_rda = FALSE
)
#> Ignoring unknown labels:
#>  colour : "Model"