@@ -76,7 +76,7 @@ write_captions <- function(dat, # converted model output object
76
76
dplyr :: slice(which.min(estimate )) | >
77
77
dplyr :: select(estimate ) | >
78
78
as.numeric() | >
79
- round(digits = 0 )
79
+ round(digits = 2 )
80
80
81
81
# maximum B
82
82
B_max <- dat | >
@@ -88,14 +88,14 @@ write_captions <- function(dat, # converted model output object
88
88
dplyr :: slice(which.max(estimate )) | >
89
89
dplyr :: select(estimate ) | >
90
90
as.numeric() | >
91
- round(digits = 0 )
91
+ round(digits = 2 )
92
92
93
93
# R0
94
94
R0 <- dat | >
95
95
dplyr :: filter(grepl(' R0' , label ) | grepl(' recruitment_virgin' , label )) | >
96
96
dplyr :: pull(estimate ) | >
97
97
as.numeric() | >
98
- round(digits = 0 )
98
+ round(digits = 2 )
99
99
100
100
# Bend <-
101
101
@@ -104,19 +104,19 @@ write_captions <- function(dat, # converted model output object
104
104
dplyr :: filter(c(grepl(' biomass' , label ) & grepl(' target' , label ) & estimate > 1 ) | label == ' biomass_msy' ) | >
105
105
dplyr :: pull(estimate ) | >
106
106
as.numeric() | >
107
- round(digits = 0 )
107
+ round(digits = 2 )
108
108
109
109
# Bmsy <-
110
110
111
111
112
112
# # relative B
113
113
# relative B min
114
114
rel_B_min <- (B_min / Btarg ) | >
115
- round(digits = 0 )
115
+ round(digits = 2 )
116
116
117
117
# relative B max
118
118
rel_B_max <- (B_max / Btarg ) | >
119
- round(digits = 0 )
119
+ round(digits = 2 )
120
120
121
121
122
122
# # mortality (F) plot
@@ -178,7 +178,7 @@ write_captions <- function(dat, # converted model output object
178
178
dplyr :: slice(which.min(estimate )) | >
179
179
dplyr :: select(estimate ) | >
180
180
as.numeric() | >
181
- round(digits = 0 )
181
+ round(digits = 2 )
182
182
183
183
# maximum landings
184
184
landings_max <- dat | >
@@ -194,7 +194,7 @@ write_captions <- function(dat, # converted model output object
194
194
dplyr :: slice(which.max(estimate )) | >
195
195
dplyr :: select(estimate ) | >
196
196
as.numeric() | >
197
- round(digits = 0 )
197
+ round(digits = 2 )
198
198
199
199
# # natural mortality (M)
200
200
# M_age_min <- # minimum age of M
@@ -313,7 +313,7 @@ write_captions <- function(dat, # converted model output object
313
313
dplyr :: slice(which.min(estimate )) | >
314
314
dplyr :: select(estimate ) | >
315
315
as.numeric() | >
316
- round(digits = 0 )
316
+ round(digits = 2 )
317
317
318
318
# maximum ssb
319
319
sr_ssb_max <- dat | >
@@ -331,7 +331,7 @@ write_captions <- function(dat, # converted model output object
331
331
dplyr :: slice(which.max(estimate )) | >
332
332
dplyr :: select(estimate ) | >
333
333
as.numeric() | >
334
- round(digits = 0 )
334
+ round(digits = 2 )
335
335
336
336
# recruitment units (plural)
337
337
# sr_units <- # this will take some thought, since recruitment_label
@@ -353,7 +353,7 @@ write_captions <- function(dat, # converted model output object
353
353
dplyr :: slice(which.min(estimate )) | >
354
354
dplyr :: select(estimate ) | >
355
355
as.numeric() | >
356
- round(digits = 0 )
356
+ round(digits = 2 )
357
357
358
358
# maximum recruitment
359
359
sr_max <- dat | >
@@ -371,16 +371,16 @@ write_captions <- function(dat, # converted model output object
371
371
dplyr :: slice(which.max(estimate )) | >
372
372
dplyr :: select(estimate ) | >
373
373
as.numeric() | >
374
- round(digits = 0 )
374
+ round(digits = 2 )
375
375
376
376
# # relative recruitment
377
377
# minimum relative recruitment
378
378
rel_recruitment_min <- (recruitment_min / R0 ) | >
379
- round(digits = 0 )
379
+ round(digits = 2 )
380
380
381
381
# maximum relative recruitment
382
382
rel_recruitment_max <- (recruitment_max / R0 ) | >
383
- round(digits = 0 )
383
+ round(digits = 2 )
384
384
385
385
386
386
# # recruitment ts
@@ -453,7 +453,7 @@ write_captions <- function(dat, # converted model output object
453
453
dplyr :: slice(which.min(estimate )) | >
454
454
dplyr :: select(estimate ) | >
455
455
as.numeric() | >
456
- round(digits = 0 )
456
+ round(digits = 2 )
457
457
458
458
# maximum recruitment deviation
459
459
recruit_dev_max <- dat | >
@@ -469,7 +469,7 @@ write_captions <- function(dat, # converted model output object
469
469
dplyr :: slice(which.max(estimate )) | >
470
470
dplyr :: select(estimate ) | >
471
471
as.numeric() | >
472
- round(digits = 0 )
472
+ round(digits = 2 )
473
473
474
474
# # tot_b (total biomass)
475
475
# biomass_start_year <- # start year of biomass plot
@@ -493,7 +493,7 @@ write_captions <- function(dat, # converted model output object
493
493
dplyr :: slice(which.min(year )) | >
494
494
dplyr :: select(year ) | >
495
495
as.numeric() | >
496
- round(digits = 0 )
496
+ round(digits = 2 )
497
497
498
498
# end year of ssb plot
499
499
# ssb_end_year <- # this will take some thought, since end_year is
@@ -515,7 +515,7 @@ write_captions <- function(dat, # converted model output object
515
515
dplyr :: slice(which.min(estimate )) | >
516
516
dplyr :: select(estimate ) | >
517
517
as.numeric() | >
518
- round(digits = 0 )
518
+ round(digits = 2 )
519
519
520
520
# maximum ssb
521
521
ssb_max <- dat | >
@@ -529,7 +529,7 @@ write_captions <- function(dat, # converted model output object
529
529
dplyr :: slice(which.max(estimate )) | >
530
530
dplyr :: select(estimate ) | >
531
531
as.numeric() | >
532
- round(digits = 0 )
532
+ round(digits = 2 )
533
533
534
534
# ssb reference point
535
535
# ssb_ref_pt <- # this will take some thought, since ref_line_val is
@@ -542,16 +542,16 @@ write_captions <- function(dat, # converted model output object
542
542
dplyr :: filter(c(grepl(' spawning_biomass' , label ) & grepl(' msy$' , label ) & estimate > 1 ) | label == ' spawning_biomass_msy$' ) | >
543
543
dplyr :: pull(estimate ) | >
544
544
as.numeric() | >
545
- round(digits = 0 )
545
+ round(digits = 2 )
546
546
547
547
# # relative ssb
548
548
# relative ssb min
549
549
rel_ssb_min <- (ssb_min / ssbtarg ) | >
550
- round(digits = 0 )
550
+ round(digits = 2 )
551
551
552
552
# relative ssb max
553
553
rel_ssb_max <- (ssb_max / ssbtarg ) | >
554
- round(digits = 0 )
554
+ round(digits = 2 )
555
555
556
556
557
557
# # spr (spawning potential ratio)
@@ -864,6 +864,9 @@ write_captions <- function(dat, # converted model output object
864
864
# 'catchability_fleet' = catchability_fleet
865
865
)
866
866
867
+ # take the values associated with the quantities and replace the df's
868
+ # placeholders with them. For example, if ssb_min = 10, this will replace
869
+ # "the minimum ssb = ssb_min" with "the minimum ssb = 10".
867
870
caps_alttext_subbed <- caps_alttext | >
868
871
dplyr :: mutate(across(where(is.character ), ~ {
869
872
for (pattern in names(patterns_replacements )){
@@ -873,7 +876,7 @@ write_captions <- function(dat, # converted model output object
873
876
.
874
877
}))
875
878
876
- # export df with substituted captions and alt text to csv
879
+ # export df with updated captions and alt text to csv
877
880
utils :: write.csv(x = caps_alttext_subbed ,
878
881
file = fs :: path(dir ,
879
882
" captions_alt_text.csv" ),
0 commit comments