From a0d468e70d8ba234438c93127e16262895e24751 Mon Sep 17 00:00:00 2001 From: ecophilina Date: Mon, 9 Sep 2024 13:57:03 -0700 Subject: [PATCH] allow months to be NULL for maturity function, so that data with missing month values could be used. --- R/maturity.R | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/R/maturity.R b/R/maturity.R index 75a6034..e6c18f2 100644 --- a/R/maturity.R +++ b/R/maturity.R @@ -7,7 +7,8 @@ #' @param year_re If `TRUE` the model will include random intercepts #' for year. #' @param months A numeric vector indicating which months to include when -#' fitting the maturity ogive. Defaults to all months. +#' fitting the maturity ogive. Defaults to including all months, but not NAs. +#' Changing to NULL will include all data including NAs. #' @param custom_maturity_at A numeric vector of two threshold codes to define #' maturity at with the first being for males and the second for females. #' Defaults to `NULL`, which brings in default values from maturity assignment @@ -63,7 +64,10 @@ fit_mat_ogive <- function(dat, type <- match.arg(type) dat <- dat[dat$sex %in% c(1, 2), , drop = FALSE] + + if(!is.null(months)){ dat <- dat[dat$month %in% months, , drop = FALSE] + } if (type == "age" && !is.null(ageing_method_codes)) { dat <- filter(dat, ageing_method %in% ageing_method_codes) @@ -83,7 +87,7 @@ fit_mat_ogive <- function(dat, maturity_code, sex, maturity_convention_code, # survey_series_id, - specimen_id, sample_id, trip_start_date + specimen_id, sample_id, month ) mat_df <- maturity_assignment