Skip to contents

Present the current length- and weight- at age (mean +/- 1 s.d., with lengths binned at 1 cm increments and ages reported in 1 year increments) with historical survey observations plotted as the range of past observations as well the historical mean +/- 1 s.d. Note that the plots automatically scale to the current survey ages + 1 (so, if your survey has fish up to 12 years old, your plots will extend to 13 years- old outlier ages may be excluded from plotting).

Usage

plot_length_and_weight_at_age(
  survey_vector,
  length_vector,
  weight_vector,
  age_vector,
  current_survey
)

Arguments

survey_vector

a vector identifying the survey a given length and weight value is from. This vector must be equal in length to length_vector, weight_vector, and age_vector.

length_vector

A vector of fish lengths (units are assumed to be cm). This vector must be equal in length to survey_vector, weight_vector, and age_vector.

weight_vector

A vector of fish weights (units are assumed to be kg). This vector must be equal in length to survey_vector, length_vector, and age_vector.

age_vector

A vector of fish ages (units are assumed to be 1 year increments). This vector must be equal in length to survey_vector, length_vector, and weight_vector.

current_survey

Identify which survey is the current survey so that it can be highlighted in plots (and removed from the historical comparison).

Value

A list with 4 items: Item 1 = A length at age plot (ggplot object). Item 2 = A weight at age plot (ggplot object). Item 3 = A dataframe summarizing the current survey length- and weight- at age Item 4 = A dataframe summarizing the historical length- and weight- at age

Examples

if (FALSE) { # \dontrun{
#load example data
library(MACEReports)
data("pollock_length_weight_age_data")

# gather plot and summary dataframes
l_w_age <- plot_length_and_weight_at_age(survey_vector =  pollock_length_weight_age_data$SURVEY,
length_vector =pollock_length_weight_age_data$FORK_LENGTH,
weight_vector = pollock_length_weight_age_data$ORGANISM_WEIGHT,
age_vector = pollock_length_weight_age_data$AGE,
current_survey = 202104)

# print the length at age plot
l_w_age[[1]]

# print the weight at age plot
l_w_age[[2]]

# get the current survey summary
current_survey_l_w_age <- l_w_age[[3]]

# and the historical summary
historical_l_w_age <- l_w_age[[4]]
} # }