Plot a given quantity across multiple models with differing end years, so as to plot retrospective peels.

plot_retrospective(
  dat,
  end_years = NULL,
  quantity = "spawning_biomass",
  show_end_year_points = TRUE,
  mohns_rho = NULL,
  group = "model",
  make_rda = FALSE,
  figures_dir = getwd(),
  ...
)

Arguments

dat

Data frame or list. A tibble or named list of tibbles (input as list()) returned from convert_output.

If inputting a list of tibbles, the first tibble's reference point defined in ref_line is used to plot a reference line or calculate relative spawning biomass.

end_years

Integer. vector of what year, relative to the maximum year present in dat, should be treated as the final year for each model. Should be <= 0.

Default: 0

quantity

String. Assessment quantity to plot (e.g., spawning biomass, biomass, recruitment, etc.). Should correspond to an existing plot_* function.

Default: "spawning_biomass"

show_end_year_points

Logical. Whether to add points at the terminal year for each model peel.

Default: TRUE

mohns_rho

Numeric. Externally calculated value(s) of Mohn's rho. Should be either a single value or of length end_years-1. Value of NULL disables reporting Mohn's rho statistic on plot. If vector, names of vector entries should match with model names.

Default: NULL

group

String. Single column that groups the data.

Default: "model"

make_rda

Logical. TRUE/FALSE; indicate whether to save the object and make an automated caption and alternative text in the form of an rda object. If TRUE, the rda will be exported to the folder indicated in the argument "figures_dir".

Default: FALSE.

figures_dir

Path. Path to the "figures" folder.

Default: getwd()

The folder is created within the path if it does not exist.

...

Arguments called from geom_line or geom_point

Value

A plot showing values of an assessment quantity across different retrospective peels.

Details

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.

Note

All plotting functions automatically recognize indexing variables and will use them in groupings and/or facetting, but will prioritize the defined group or facet by the function arguments. @seealso process_data().

Examples

plot_retrospective(
  dat = ss3_simple,
  end_years = 0:-5,
  quantity = "spawning_biomass",
  show_end_year_points = TRUE
)
#> ℹ Only 1 model detected in `dat`. Function expects multiple models corresponding to unique retrospective peels.
#> → `end_years` provided without names. names automatically applied.
#> ! Multiple modules found in data. 
#> ℹ Environment not interactive. Selecting recruit.
#> ! spawning_biomass_msy not found for data

plot_retrospective(
  dat = ss3_simple,
  end_years = 0:-5,
  quantity = "spr",
  show_end_year_points = TRUE,
  interactive = FALSE,
  module = "derived_quants"
)
#> ℹ Only 1 model detected in `dat`. Function expects multiple models corresponding to unique retrospective peels.
#> → `end_years` provided without names. names automatically applied.
#> ! Multiple modules found in data. 
#> ℹ Environment not interactive. Selecting sprseries.
#> ! spr_target not found for data

plot_retrospective(
  dat = ss3_simple,
  end_years = 0:-5,
  quantity = "spr",
  show_end_year_points = TRUE,
  mohns_rho = c(0.023, 0.01, 1.25, 0.845, 0.068),
  interactive = FALSE,
  module = "derived_quants"
)
#> ℹ Only 1 model detected in `dat`. Function expects multiple models corresponding to unique retrospective peels.
#> → `end_years` provided without names. names automatically applied.
#> ! Invalid number of mohn's rho values provided. Should be number of peels - 1. Mohn's rho values will not be reported.
#> ! Multiple modules found in data. 
#> ℹ Environment not interactive. Selecting sprseries.
#> ! spr_target not found for data