Skip to content

Commit 52721f2

Browse files
author
Will Butler
committed
predator.prey: check "length" exists before renaming
1 parent 2d6c6f0 commit 52721f2

1 file changed

Lines changed: 2 additions & 2 deletions

File tree

R/g3_fit.R

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -377,7 +377,7 @@ g3_fit_inner <- function(tmp,
377377
dplyr::ungroup() %>%
378378
dplyr::mutate(length = (.data$upper + .data$lower)/2) %>%
379379
dplyr::select(-c(.data$lower, .data$upper))
380-
}
380+
}
381381

382382
if ('age' %in% names(suitability)){
383383
suitability$age <- as.numeric(gsub('age', '', suitability$age))
@@ -650,11 +650,11 @@ g3_fit_inner <- function(tmp,
650650
predator.prey <-
651651
lapply(split(fleet_reports, list(fleet_reports$stock, fleet_reports$fleet)), function(x, suits){
652652
if (nrow(x) == 0) return(NULL)
653+
if ("length" %in% names(suits)) suits <- suits %>% rename(avg.length = length)
653654
suppressMessages(
654655
x %>%
655656
dplyr::left_join(
656657
suits %>%
657-
dplyr::rename(avg.length = length) %>%
658658
dplyr::filter(.data$stock %in% unique(x$stock),
659659
.data$fleet %in% unique(x$fleet)) %>%
660660
dplyr::select(dplyr::where(not_all_na))

0 commit comments

Comments
 (0)