From 96fda8c0de077b66e2c9b22067d08230eab5f191 Mon Sep 17 00:00:00 2001 From: ecophilina Date: Tue, 8 Oct 2024 14:39:54 -0700 Subject: [PATCH] change fit_mat_ogive function to use sample_date preferentially over trip_start_date to generate month when month is missing from a data frame --- R/maturity.R | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/R/maturity.R b/R/maturity.R index e6c18f2..19f1482 100644 --- a/R/maturity.R +++ b/R/maturity.R @@ -49,7 +49,12 @@ fit_mat_ogive <- function(dat, link <- match.arg(link) if(!("month" %in% names(dat))){ - dat <- mutate(dat, month = lubridate::month(trip_start_date)) + if(("sample_date" %in% names(dat))){ + dat <- mutate(dat, month = lubridate::month(sample_date)) + } else { + dat <- mutate(dat, month = lubridate::month(trip_start_date)) + print("Assigned a month using trip start dates rather than sample dates.") + } } dat <- dat %>% filter(maturity_convention_code != 9)