@@ -124,19 +124,19 @@ g3_fit <- function(model,
124124 # # --------------------------------------------------------------
125125 # # Catch distributions
126126 # # --------------------------------------------------------------
127- if (any(grepl(' ^cdist_.+__num $' , names(tmp )))){
127+ if (any(grepl(' ^cdist_.+__(num|wgt) $' , names(tmp )))){
128128
129129 # # To-do: add in age and length attributes from stock objects
130130 # # Merge together catch distribution observations and predictions
131131 dat <-
132- tmp [grep(' ^cdist_.+__num $' , names(tmp ))] %> %
132+ tmp [grep(' ^cdist_.+__(num|wgt) $' , names(tmp ))] %> %
133133 purrr :: map(as.data.frame.table , stringsAsFactors = FALSE ) %> %
134134 dplyr :: bind_rows(.id = ' comp' ) %> %
135- dplyr :: mutate(data_function = gsub(' (cdist)_([A-Za-z]+)_(.+)_(model|obs)__num ' , ' \\ 2' , .data $ comp ),
136- # type = gsub('(cdist)_([A-Za-z]+)_([A-Za-z]+)_(.+)_(model|obs)__num ', '\\3', .data$comp),
137- # fleetnames = gsub('(cdist)_([A-Za-z]+)_([A-Za-z]+)_(.+)_(model|obs)__num ', '\\4', .data$comp),
138- origin = gsub(' (cdist)_([A-Za-z]+)_(.+)_(model|obs)__num ' , ' \\ 4' , .data $ comp ),
139- name = gsub(' (cdist)_([A-Za-z]+)_(.+)_(model|obs)__num ' , ' \\ 3' , .data $ comp ),
135+ dplyr :: mutate(data_function = gsub(' (cdist)_([A-Za-z]+)_(.+)_(model|obs)__(num|wgt) ' , ' \\ 2' , .data $ comp ),
136+ # type = gsub('(cdist)_([A-Za-z]+)_([A-Za-z]+)_(.+)_(model|obs)__(num|wgt) ', '\\3', .data$comp),
137+ # fleetnames = gsub('(cdist)_([A-Za-z]+)_([A-Za-z]+)_(.+)_(model|obs)__(num|wgt) ', '\\4', .data$comp),
138+ origin = gsub(' (cdist)_([A-Za-z]+)_(.+)_(model|obs)__(num|wgt) ' , ' \\ 4' , .data $ comp ),
139+ name = gsub(' (cdist)_([A-Za-z]+)_(.+)_(model|obs)__(num|wgt) ' , ' \\ 3' , .data $ comp ),
140140 # length = gsub('len', '', .data$length) %>% as.numeric(),
141141 area = tryCatch(as.numeric(as.factor(.data $ area )),
142142 error = function (z ) 1 )) %> %
0 commit comments