-
Notifications
You must be signed in to change notification settings - Fork 1
/
index.Rmd
232 lines (211 loc) · 6.21 KB
/
index.Rmd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
---
title: "Stock status update with application of management procedures for Pacific Herring (*Clupea pallasii*) in British Columbia`:` Status in 2024 and forecast for 2025"
french_title: "Mise à jour de l'état des stocks avec application des procédures de gestion pour le hareng du Pacifique (*Clupea pallasii*) en Colombie-Britannique `:` État en 2024 et prévisions pour 2025"
assess_year: 2024
work_done_year: 2025
t_work_done_month: Month
report_number: 000
isbn_en: 978-0-660-00000-0
isbn_fr: 978-0-660-00000-0
t_approver: "Andrew Thomson \n\n\n Regional Director"
approval_year: 2024
t_approval_month: September
approval_day: 27
process_year: 2024
t_process_month: September
process_day: 23
t_branch: Science Branch
t_region: Pacific Region
output:
csasdown:::sr_pdf:
french: FALSE
prepub: FALSE
copy_sty: TRUE
line_nums: FALSE
line_nums_mod: 1
draft_watermark: FALSE
highlight: tango
type: sr
knit: bookdown::render_book
site: bookdown::bookdown_site
link-citations: TRUE
bibliography: bib/refs.bib
# bibliography: bib/refs_fr.bib
lot: TRUE
lof: TRUE
header-includes:
- \usepackage{needspace}
- \usepackage{afterpage}
# - \usepackage{textpos}
# - \usepackage{color}
---
\sloppy
```{r libraries, echo=FALSE, cache=FALSE, message=FALSE, results='hide', warning=FALSE}
library(knitr)
library(rmarkdown)
library(stringr)
library(tidyverse)
library(directlabels)
library(reshape2)
library(kableExtra)
library(here)
library(rosettafish)
library(csasdown)
library(gfutilities)
library(gfiscamutils)
library(ggrepel)
library(herringutils)
library(gcookbook)
library(readr)
library(zoo)
```
```{r setup, echo=FALSE, cache=FALSE, message=FALSE, results='hide', warning=FALSE}
if (is_latex_output()) {
knitr_figs_dir <- "knitr-figs-pdf/"
knitr_cache_dir <- "knitr-cache-pdf/"
fig_out_type <- "pdf"
} else {
knitr_figs_dir <- "knitr-figs-docx/"
knitr_cache_dir <- "knitr-cache-docx/"
fig_out_type <- "ragg_png"
}
fig_asp <- 0.618
fig_width <- 6.5
fig_out_width <- "6.5in"
fig_dpi <- 320
fig_align <- "center"
fig_pos <- "ht"
opts_chunk$set(
collapse = TRUE,
warning = FALSE,
message = FALSE,
comment = "#>",
fig.path = knitr_figs_dir,
cache.path = knitr_cache_dir,
fig.asp = fig_asp,
fig.width = fig_width,
out.width = fig_out_width,
echo = FALSE,
cache.comments = FALSE,
dev = fig_out_type,
dpi = fig_dpi,
fig.align = fig_align,
fig.pos = "H"
)
options(
xtable.comment = FALSE,
kableExtra.latex.load_packages = FALSE,
width = 80,
scipen = 999,
dplyr.summarise.inform = FALSE,
ggrepel.max.overlaps = Inf
)
```
```{r metadata}
assess_yr <- metadata$assess_year
meta_out <- metadata$output
if (is.null(meta_out)) {
options(french = FALSE)
} else {
if (length(grep("pdf", names(meta_out)))) {
french <- meta_out$`csasdown:::sr_pdf`$french
options(french = french)
prepub <- meta_out$`csasdown:::sr_pdf`$prepub
} else if (length(grep("word", names(meta_out)))) {
french <- meta_out$`csasdown::sr_word`$french
options(french = french)
prepub <- meta_out$`csasdown::sr_word`$prepub
}
}
if (french) {
t_title_short <- paste("État du hareng du Pacifique en", assess_yr,
"et prévisions pour", assess_yr + 1)
t_isbn <- metadata$isbn_fr
t_csl <- "csl/csas-french.csl"
options(OutDec = ",")
} else {
t_title_short <- paste("Pacific Herring status in", assess_yr,
"and forecast for", assess_yr + 1)
t_isbn <- metadata$isbn_en
t_csl <- "csl/csas.csl"
}
t_work_done_month <- en2fr(
metadata$t_work_done_month, translate = french, case = "title"
)
t_approver <- gsub(
pattern = "Regional Director",
x = metadata$t_approver,
replacement = en2fr(x = "Regional Director",
translate = french, case = "title")
)
t_approval_month <- en2fr(
metadata$t_approval_month, translate = french, case = "title"
)
t_process_month <- en2fr(
metadata$t_process_month, translate = french, case = "title"
)
t_branch <- en2fr(metadata$t_branch, translate = french, case = "none")
t_region <- en2fr(metadata$t_region, translate = french, case = "none")
t_cat_no <- paste0(
"Fs70-5/",
metadata$work_done_year,
"-",
str_pad(string = metadata$report_number, width = 3, pad = "0"),
ifelse(french, "F", "E"),
"-PDF"
)
```
```{r output-options}
keep_non_CC <- TRUE # FALSE to provide preliminary CC report
slides <- FALSE # Make figures for powerpoint slides
keep_sog <- TRUE # Keep or omit SoG
```
```{r models, cache=FALSE}
models_dir <- here("models")
major_stock_dir <- list("HG", "PRD", "CC", "SoG", "WCVI")
minor_stock_dir <- list("A27", "A2W")
special_stock_dir <- list("A10")
mcmc_length <- 5000000 # Default: 5,000,000
mcmc_samp_freq <- 1000 # Default: 1,000
mcmc_burnin <- 1000 # Default: 1,000
retro_yrs <- 1:10 # Default: 1:10
run_sca_models <- FALSE # Run SCA for SARs in `major_stock_dir`
rebuild_rdata_model_files <- FALSE # Rebuild RData files (replace existing)
run_retros <- FALSE # Run retrospectives
source(here("R", "run-sca.R"))
source(here("R", "model-setup.R"))
source(here("R", "variable-setup.R"))
source(here("R", "hcr.R"))
theme_set(herring_theme())
```
<!-- Distributions -->
\newcommand{\dUnif}[2]{$\mathcal{U}\left(#1, #2\right)$}
\newcommand{\dNorm}[2]{$\mathcal{N}\left(#1, #2\right)$}
\newcommand{\dLognorm}[2]{$\emph{Lognormal}\left(#1, #2\right)$}
\newcommand{\dBeta}[2]{$\emph{Beta}\left(#1, #2\right)$}
\newcommand{\dGamma}[2]{$\emph{Gamma}\left(#1, #2\right)$}
<!-- Other math -->
\newcommand{\lognorm}{\text{ln}}
\newcommand{\SB}{\mli{`r en2fr("SB", translate = french)`}}
\newcommand{\BR}{\mli{BR}}
\newcommand{\AVE}{\text{`r en2fr("AVE", translate = french)`}}
---
title_short: `r t_title_short`
isbn: `r t_isbn`
approver: `r t_approver`
approval_month: `r t_approval_month`
work_done_month: `r t_work_done_month`
branch: `r t_branch`
region: `r t_region`
cat_no: `r t_cat_no`
process_month: `r t_process_month`
csl: `r t_csl`
---
<!-- Compile the PDF on the command line: -->
<!-- bookdown::render_book("index.Rmd") -->
<!-- TODO: update to render_sar() next year -->
<!-- csasdown::render_sar() -->
<!-- Make French version: -->
<!-- 1. Set `french` to `TRUE` -->
<!-- 2. Select the French bibliography -->
<!-- 3. Select French children in "_bookdown.yml" -->