-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy path8_Tables.Rmd
1426 lines (1164 loc) · 61 KB
/
8_Tables.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
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
\captionsetup[table]{labelformat=simple,format=plain,labelsep=period}
<!-- ====================================================================== -->
<!-- **************************** ****************************** -->
<!-- ****************************BEGIN TABLES****************************** -->
<!-- **************************** ***************************** -->
<!-- ======================================================================-->
#Tables
## Northern Model Tables
<!-- ********************************************************************** -->
<!-- *********************Commercial landings TABLES*********************** -->
<!-- ********************************************************************** -->
```{r, results = 'asis'}
# Northern_catch = read.csv('./txt_files/Northern.Catch.csv')
# colnames(Northern_catch) = c('Year',
# 'Commercial Trawl',
# 'Hake Bycatch',
# 'Rec CA and OR',
# 'Rec WA')
# data frame with years from model output
Northern_catch <-
data.frame(Yr = sort(unique(mod1$catch$Yr[mod1$catch$Yr>=mod1$startyr])),
ComRet=NA,
ComDis=NA,
ComTot=NA,
HakeByCatch=NA,
RecORandCA=NA,
RecWA_N=NA,
RecWA_B=NA)
# loop over years to fill in catches
for(irow in 1:nrow(Northern_catch)){
# get year
y <- Northern_catch$Yr[irow]
# get retained biomass for fleet 1 (commercial)
ret <- mod1$catch$ret_bio[mod1$catch$Fleet==1 &
mod1$catch$Yr==y]
tot <- mod1$catch$kill_bio[mod1$catch$Fleet==1 &
mod1$catch$Yr==y]
dis <- tot - ret
Northern_catch$ComRet[irow] <- round(ret,1)
Northern_catch$ComDis[irow] <- round(dis,1)
Northern_catch$ComTot[irow] <- round(tot,1)
# get dead biomass for fleet 2 (hake)
catch <- mod1$catch$kill_bio[mod1$catch$Fleet==2 &
mod1$catch$Yr==y]
Northern_catch$HakeByCatch[irow] <- round(catch,1)
# get dead biomass for fleet 3 (RecORandCA)
catch <- mod1$catch$kill_bio[mod1$catch$Fleet==3 &
mod1$catch$Yr==y]
Northern_catch$RecORandCA[irow] <- round(catch,1)
# get dead NUMBERS for fleet 4 (RecWA)
catch <- mod1$catch$kill_bio[mod1$catch$Fleet==4 &
mod1$catch$Yr==y]
Northern_catch$RecWA_N[irow] <- round(catch,0)
# get dead BIOMASS for fleet 4 (RecWA)
catch <- mod1$catch$kill_bio[mod1$catch$Fleet==4 &
mod1$catch$Yr==y]
Northern_catch$RecWA_B[irow] <- round(catch,1)
}
# calculate total catch by summing biomass columns
Northern_catch$Total <-
Northern_catch$ComTot +
Northern_catch$HakeByCatch +
Northern_catch$RecORandCA +
Northern_catch$RecWA_B
# checked results against mod1$sprseries$Dead_Catch_B and it matches
colnames(Northern_catch) = c('Year',
'Comm (retain, mt)',
'Comm (discard, mt)',
'Comm (total, mt)',
'Hake Bycatch (mt)',
'Rec CA and OR (mt)',
'Rec WA (1000s)',
'Rec WA (mt)',
'Total (mt)')
# strange hack to get column widths while keeping right alignment
# found in 2nd answer (by Raoul) to question here:
# https://stackoverflow.com/questions/2686320/how-to-put-a-newline-into-a-column-header-in-an-xtable-in-r
for(icol in 1:9){
colnames(Northern_catch)[icol] <- paste0("\\multicolumn{1}{p{0.6in}}{\\centering ",
colnames(Northern_catch)[icol],
"}")
}
caption <- 'Catch timeseries for the Northern model. Commercial discards are estimated within the model based on estimated selectivity and retention functions. Numbers for the Recreational catch in Washington are converted to weight in the model based on the weight-length relationships combined with estimated growth and selectivity for this fleet.'
# create table
Northern_catch.table = xtable(Northern_catch,
caption =caption,
label = 'tab:Northern_catch',
digits=c(0,0,1,1,1,1,1,0,1,1))
addtorow <- list()
addtorow$pos <- list()
addtorow$pos[[1]] <- c(0)
addtorow$command <- c(paste("\\hline \n",
"\\endhead \n",
"\\hline \n",
"\\multicolumn{3}{l}",
"{\\footnotesize Continued on next page} \n",
"\\endfoot \n",
"\\endlastfoot \n",sep=""))
# Print
print(Northern_catch.table,
include.rownames = FALSE,
caption.placement = 'top',
tabular.environment = 'longtable',
floating = FALSE,
sanitize.colnames.function=function(x){x},
add.to.row = addtorow)
```
<!-- ********************************************************************** -->
<!-- *********************Management Performance Table NORTH*************** -->
<!-- ********************************************************************** -->
```{r, results = 'asis'}
mngmnt = read.csv('./txt_files/Exec_mngmt_performance.N.csv')
mngmnt$Catch <- c(round(mod1$sprseries$Dead_Catch_B[mod1$sprseries$Yr %in% 2007:2016]),
"-","-")
colnames(mngmnt) = c('Year',
'OFL (mt; ABC prior to 2011)',
'ABC (mt)',
'ACL (mt; OY prior to 2011)',
'Estimated total catch (mt)')
# Create the management performance table
mngmnt.table.N = xtable(mngmnt,
caption=c('Northern model recent total catch
relative to the management guidelines.
Estimated total catch includes estimated discarded
biomass. Note: the OFL was termed the ABC prior to
implementation of FMP Amendment 23 in 2011.
The ABC was redefined to reflect the uncertainty
in estimating the OFL under Amendment 23.
Likewise, the ACL was termed the OY prior to 2011.'),
label='tab:mnmgt_perform.N')
# Add alignment
align(mngmnt.table.N) = c('l',
'>{\\raggedleft}p{1in}',
'>{\\centering}p{1in}',
'>{\\centering}p{1in}',
'>{\\centering}p{1in}',
'>{\\centering}p{1in}')
print(mngmnt.table.N, include.rownames = FALSE, caption.placement = 'top',
sanitize.text.function = function(x){x}, scalebox = .9)
```
\newpage
<!-- ********************************************************************** -->
<!-- *******************Commercial Discards TABLES************************* -->
<!-- ********************************************************************** -->
```{r, results = 'asis'}
Northern_discard = read.csv('./txt_files/Northern.Discards.csv')
colnames(Northern_discard) = c('Year',
'Discard fraction',
'CV')
# Index of abundance summary, create table
Northern_discard.table = xtable(Northern_discard,
caption ='Timeseries of observed discard fractions and the estimated CV for the commercial fleet in the Northern model.',
label = 'tab:Northern_discard',
digits=4)
# Print
print(Northern_discard.table,
include.rownames = FALSE,
caption.placement = 'top',
sanitize.text.function = function(x){x})
```
\newpage
<!-- Northern Lengths -->
```{r, results = 'asis'}
Northern_length = read.csv('./txt_files/Northern.Lengths.csv')
colnames(Northern_length) = c('Year',
'Comm. Fish',
'Comm. Tows',
'Hake Fish',
'Hake Tows',
'Tri. Fish',
'Tri. Tows',
'NWFSC Fish',
'NWFSC Tows',
'Rec-WA Fish',
'Rec-OR+CA Fish')
# strange hack to get column widths while keeping right alignment
colnames(Northern_length) <- paste0("\\multicolumn{1}{p{0.45in}}{\\centering ",
colnames(Northern_length), "}")
# Length comp sample sizes, create table
Northern_length.table = xtable(Northern_length,
caption = 'Time series of length composition sample sizes for the Northern model. Numbers of fish sampled and number of tows with samples are provided for all but the recreational fleets where only the number of fish was available. "Comm." refers to the Commercial fishery. "Hake" to the bycatch in the At-Sea Hake fish" and "Tri." to the triennial survey.',
label = 'tab:Northern_length',
digits=3)
addtorow <- list()
addtorow$pos <- list()
addtorow$pos[[1]] <- c(0)
addtorow$command <- c(paste("\\hline \n",
"\\endhead \n",
"\\hline \n",
"\\multicolumn{3}{l}",
"{\\footnotesize Continued on next page} \n",
"\\endfoot \n",
"\\endlastfoot \n",sep=""))
# Print
print(Northern_length.table,
include.rownames = FALSE,
caption.placement = 'top',
tabular.environment = 'longtable',
floating = FALSE,
sanitize.colnames.function=function(x){x},
add.to.row = addtorow)
```
\newpage
<!-- Northern ages -->
```{r, results = 'asis'}
Northern_age = read.csv('./txt_files/Northern.Ages.csv')
colnames(Northern_age) = c('Year',
'Trawl',
'Tows',
'Triennial',
'Tows',
'NWFSCcombo',
'Tows',
'Rec WA')
# Index of abundance summary, create table
Northern_age.table = xtable(Northern_age,
caption ='Age timeseries for the Northern model.',
label = 'tab:Northern_age',
digits=3)
addtorow <- list()
addtorow$pos <- list()
addtorow$pos[[1]] <- c(0)
addtorow$command <- c(paste("\\hline \n",
"\\endhead \n",
"\\hline \n",
"\\multicolumn{3}{l}",
"{\\footnotesize Continued on next page} \n",
"\\endfoot \n",
"\\endlastfoot \n",sep=""))
# Print
print(Northern_age.table,
include.rownames = FALSE,
caption.placement = 'top',
tabular.environment = 'longtable',
floating = FALSE,
add.to.row = addtorow)
```
\newpage
<!-- ***********Sample sizes for surveys************************* -->
```{r, results = 'asis'}
Triennial_hauls = read.csv('./txt_files/Triennial survey sample sizes.csv')
colnames(Triennial_hauls) = c('Year',
'Hauls in Northern area',
'Hauls with Yellowtail in Northern area',
'Hauls in Southern area',
'Hauls with Yellowtail in Southern area')
# Index of abundance summary, create table
Triennial_hauls.table = xtable(Triennial_hauls,
caption = c('Number of hauls by year and area in total and with Yellowtail Rockfish for the Triennial bottom trawl survey.'),
label = 'tab:Triennial_hauls',
digits = 0)
align(Triennial_hauls.table) = c('l','c',
'>{\\centering}p{1.2in}',
'>{\\centering}p{1.2in}',
'>{\\centering}p{1.2in}',
'>{\\centering}p{1.2in}')
# Print table
print(Triennial_hauls.table,
include.rownames=FALSE,
caption.placement='top',
sanitize.colnames.function=function(x){x},
sanitize.text.function = function(x){x})
```
```{r, results = 'asis'}
NWFSCcombo_hauls = read.csv('./txt_files/NWFSCcombo survey sample sizes.csv')
colnames(NWFSCcombo_hauls) = c('Year',
'Hauls in Northern area',
'Hauls with Yellowtail in Northern area',
'Hauls in Southern area',
'Hauls with Yellowtail in Southern area')
# Index of abundance summary, create table
NWFSCcombo_hauls.table = xtable(NWFSCcombo_hauls,
caption = c('Number of hauls by year and area in total and with Yellowtail Rockfish for the NWFSCcombo bottom trawl survey.'),
label = 'tab:NWFSCcombo_hauls',
digits = 0)
# Add alignment
align(NWFSCcombo_hauls.table) = c('l','c',
'>{\\centering}p{1.2in}',
'>{\\centering}p{1.2in}',
'>{\\centering}p{1.2in}',
'>{\\centering}p{1.2in}')
# Print table
print(NWFSCcombo_hauls.table,
include.rownames=FALSE,
caption.placement='top',
sanitize.text.function = function(x){x})
```
<!-- ---------------------------------------------------------------------- -->
<!-- ***********Indices of abundance summary table************************* -->
```{r, results = 'asis'}
Index_summary = read.csv('./txt_files/Index_summary.csv')
colnames(Index_summary) = c('Years',
'Name',
'Fishery ind.',
'Method',
'Used in model')
# Index of abundance summary, create table
Index_summary.table = xtable(Index_summary,
caption = c('Summary of the biomass/abundance
time series used in the Northern model.'),
label = 'tab:Index_summary',
digits = 0)
# Print index summary table
print(Index_summary.table,
include.rownames=FALSE,
caption.placement='top',
sanitize.text.function = function(x){x})
```
<!-- ---------------------------------------------------------------------- -->
\newpage
<!-- ********************************************************************** -->
<!-- ************ CPUE Table ************************* -->
<!-- ********************************************************************** -->
```{r, results = 'asis'}
Northern_CPUE = read.csv('./txt_files/Northern.CPUE.csv')
colnames(Northern_CPUE) = c('Year',
'Commercial Trawl',
'SE',
'Hake Bycatch',
'SE',
'NWFSCcombo',
'SE',
'Triennial',
'SE')
# Index of abundance summary, create table
Northern_CPUE.table = xtable(Northern_CPUE,
caption ='CPUE timeseries for the Northern model. The SE values represent standard error on a log scale, which is similar to a CV. The Commercial Trawl and Hake Bycatch indices were not included in the likelihood of the final model.',
label = 'tab:Northern_CPUE',
digits=2)
# Print
print(Northern_CPUE.table,
include.rownames = FALSE,
caption.placement = 'top',
sanitize.text.function = function(x){x})
```
\newpage
<!-- ********************************************************************** -->
<!-- ************Recreational dockside survey TABLES*********************** -->
<!-- ********************************************************************** -->
<!-- ********************************************************************** -->
<!-- ************Recreational onboard observer index TABLES**************** -->
<!-- ********************************************************************** -->
<!-- ********************************************************************** -->
<!-- ************Fishery dependent biological sampling TABLES************* -->
<!-- ********************************************************************** -->
<!-- ====================================================================== -->
<!-- ******************START BIOLOGICAL DATA TABLES************************ -->
<!-- ====================================================================== -->
<!-- ********************************************************************** -->
<!-- ***********************Weight-length TABLES*************************** -->
<!-- ********************************************************************** -->
<!-- ********************************************************************** -->
<!-- ******************Maturity and Fecundity TABLES*********************** -->
<!-- ********************************************************************** -->
<!-- ********************************************************************** -->
<!-- **********************Age Structure TABLES**************************** -->
<!-- ********************************************************************** -->
<!-- ====================================================================== -->
<!-- ********************BASE-CASE MODEL 1 TABLES************************** -->
<!-- **REPEAT THIS SECTION AND EDIT AS NEEDED IF YOU HAVE MULTIPLE MODELS** -->
<!-- ====================================================================== -->
\FloatBarrier
<!-- ***********MODEL 1 PARAMETERS***************************************** -->
\begin{landscape}
```{r, results='asis'}
# If you use this for more than one model = change mod1 to mod2 or mod3
mod_params = mod1$parameters[-c(grep('Recr',mod1$parameters$Label),
grep('Impl',mod1$parameters$Label)),
(names(mod1$parameters) %in%
c("Num","Label","Value","Phase","Min",
"Max","Status","Parm_StDev",
"Pr_type","Prior","Pr_SD"))]
# Combine bounds into one column
mod_params$Min = paste('(', mod_params$Min, ', ', mod_params$Max, ')', sep='')
# Combine prior info to one column
#mod_params$Pr_type = gsub('No_prior', 'None', mod_params$Pr_type)
mod_params$Pr_type = ifelse(mod_params$Pr_type == 'No_prior' , 'None',
paste(mod_params$Pr_type,' (', mod_params$Prior,
', ', mod_params$Pr_SD, ')', sep = ''))
# Remove the max, prior and prior sd columns
drops = c('Max', 'Prior', 'Pr_SD')
mod_params = mod_params[, !(names(mod_params) %in% drops)]
# Add column names
colnames(mod_params) = c('No.',
'Parameter',
'Value',
'Phase',
'Bounds',
'Status',
'SD',
'Prior (Exp.Val, SD) ')
# Model 1 model parameters
mod_params.table = xtable(mod_params,
caption=c(paste('List of parameters used in
the base Northern model, including estimated
values and standard deviations (SD),
bounds (minimum and maximum),
estimation phase (negative values indicate
not estimated), status (indicates if
parameters are near bounds, and prior type
information (mean, SD).'
, sep='')),
label='tab:Model1_params',
digits = c(0,0,0,3,0,3,0,3,0))
# Add alignment
align(mod_params.table) = c('lrlrrcccl')
# Add alignment
# align(mod_params.table) = c('l',
# '>{\\raggedright}p{.4in}',
# '>{\\raggedright}p{.8in}',
# '>{\\centering}p{.3in}',
# '>{\\centering}p{.3in}',
# '>{\\centering}p{.4in}',
# '>{\\centering}p{.4in}',
# '>{\\centering}p{.4in}',
# '>{\\centering}p{.4in}',
# '>{\\centering}p{.5in}',
# '>{\\centering}p{.5in}')
# Add "continued on next page"" footnote
addtorow <- list()
addtorow$pos <- list()
addtorow$pos[[1]] <- c(0)
addtorow$command <- c(paste("\\hline \n",
"\\endhead \n",
"\\hline \n",
"\\multicolumn{3}{l}",
"{\\footnotesize Continued on next page} \n",
"\\endfoot \n",
"\\endlastfoot \n",sep=""))
# Print Model 1 parameters
print(mod_params.table,
include.rownames = FALSE,
caption.placement = 'top',
tabular.environment = 'longtable',
floating = FALSE,
add.to.row = addtorow)
```
\end{landscape}
<!-- ---------------------------------------------------------------------- -->
\newpage
<!-- ***********MODEL 1 SENSITIVITY TABLE(S)******************************* -->
```{r, results = 'asis'}
# Read in/organize sensitivity file, change column names, caption
Sens_model1 = read.csv('./txt_files/comparison_table_sens.N.csv')
namelist <- c("Quantity",
"Base Model",
"McAllister-Ianelli weights",
"M prior Age64",
"M fixed Age64",
"Include commercial index",
"Include hake bycatch index",
"Include commercial and hake indices")
colnames(Sens_model1) = namelist
# Create sensitivities table
Sens_model1.table = xtable(Sens_model1,
caption = c('Results of sensitivity analyses for the Northern model.'),
label = 'tab:Sensitivity_model1', digits = 2)
# Add alignment - this uses centered aligment of .7 inches for all columns 2+,
# You can change this easily to have variable columns width after you know how many
# colunns your final table has
align(Sens_model1.table) = c('l','l', rep('>{\\centering}p{.7in}', dim(Sens_model1)[2]-1))
# '>{\\centering}p{.6in}',
# '>{\\centering}p{.5in}',
# '>{\\centering}p{.5in}',
# '>{\\centering}p{.6in}',
# '>{\\centering}p{.5in}',
# '>{\\centering}p{.6in}',
# '>{\\centering}p{.6in}',
# '>{\\centering}p{.6in}')
# Print model 1 sensitivity table
print(Sens_model1.table,
include.rownames = FALSE,
caption.placement = 'top',
floating.environment = 'sidewaystable',
scalebox = .9)
```
<!-- ---------------------------------------------------------------------- -->
\newpage
<!-- ***********MODEL 1 REFERENCE POINTS TIME SERIES TABLE***************** -->
```{r}
# Total biomass, extract and subset
Bio_all = mod1$timeseries[, c('Yr', 'Bio_all')]
Bio_allyrs = subset(Bio_all, Yr > (Dat_start_mod1 - 1) & Yr < (LastYR + 1))
# Spawning biomass, extract and subset, and turn into scientific notation
SpawningB = mod1$derived_quants[grep('SPB', mod1$derived_quants$Label), ]
SpawningB = SpawningB[c(-1, -2), ]
SpawningByrs = SpawningB[SpawningB$Label >= paste('SPB_', Dat_start_mod1, sep='') &
SpawningB$Label <= paste('SPB_', LastYR, sep=''), ]
SpawningB_units = ''
if(mean(SpawningByrs$Value) > 1000000){
SpawningB_units <- "million"
SpawningByrs$Value <- SpawningByrs$Value/1000000
}
# Depletion, extract, rename and subset
Depl_years = as.data.frame(seq(Dat_start_mod1, LastYR, 1))
colnames(Depl_years) = 'Yr'
Depl_years$Depl = 0
Depletion = mod1$derived_quants[grep('Bratio', mod1$derived_quants$Label), ]
Depletionyrs = Depletion[Depletion$Label >= paste0('Bratio_', Dat_start_mod1) &
Depletion$Label <= paste0('Bratio_', LastYR), ]
Depletionyrs$Yr = Depletionyrs$Label1 = substr(Depletionyrs$Label,
(nchar(Depletionyrs$Label) + 1) - 4,
nchar(Depletionyrs$Label))
# Make sure depletion is numeric and merge ...
Depletionyrs$Yr = as.numeric(Depletionyrs$Yr)
Depleteyrs = merge(Depl_years, Depletionyrs, all.x=T, all.y=T, by.x='Yr', by.y='Yr')
Depleteyrs[is.na(Depleteyrs)] <- 0
Depleteyrs$total = Depleteyrs$Depl + Depleteyrs$Value
# Recruits, extract and subset
Recruit = mod1$derived_quants[grep('Recr', mod1$derived_quants$Label), ]
Recruit = Recruit[c(-1, -2), ]
Recruityrs = Recruit[Recruit$Label >= paste('Recr_', Dat_start_mod1, sep='') &
Recruit$Label <= paste('Recr_', LastYR, sep=''), ]
# Landings/total catch, extract and subset years
Landings = mod1$sprseries[ , c('Yr','Dead_Catch_B')]
Landingsyrs = subset(Landings, Yr > (Dat_start_mod1 - 1) & Yr < (LastYR + 1))
# Relatvie exploitation rate, extract, subset and merge
Exploit = mod1$derived_quants[grep('F', mod1$derived_quants$Label), ]
Exploit = Exploit[c(-1, -2), ]
Exploityrs = Exploit[Exploit$Label >= paste('F_', Dat_start_mod1, sep = '') &
Exploit$Label <= paste('F_', LastYR, sep = ''), ]
Exploityrs$Yr = Exploityrs$Label1 = substr(Exploityrs$Label,
(nchar(Exploityrs$Label) + 1) - 4,
nchar(Exploityrs$Label))
Exploityrs$Yr = as.numeric(Exploityrs$Yr)
Exploited = merge(Depl_years, Exploityrs, all.x=T, all.y=T, by.x='Yr', by.y='Yr')
Exploited[is.na(Exploited)] <- 0
Exploited$total = Exploited$Depl + Exploited$Value
# SPR, extract and subset years
SPR = mod1$sprseries[, c('Yr', 'SPR')]
SPRyrs = subset(SPR, Yr > (Dat_start_mod1 - 1) & Yr < (LastYR + 1))
# Bind all the columns together for the table
Timeseries = as.data.frame(cbind(seq(Dat_start_mod1, LastYR, 1),
Bio_allyrs$Bio_all,
SpawningByrs$Value,
Depleteyrs$total,
Recruityrs$Value,
Landingsyrs$Dead_Catch_B,
Exploited$total,
SPRyrs$SPR))
# Add colulmn names
colnames(Timeseries)=c('Yr',
'Total biomass (mt)',
'Spawning output (trillions of eggs)',
'Relative spawning output',
'Age-0 recruits',
'Total catch (mt)',
'Relative exploitation rate',
'SPR')
# Make year a factor so you don't have a decimal
Timeseries$Yr = as.factor(Timeseries$Yr)
# Remove 2015 values for last three columns since year isn't complete
Timeseries[nrow(Timeseries), c((ncol(Timeseries) - 2):ncol(Timeseries))] <- NA
```
```{r, results='asis'}
# Create the time series table
Timeseries.table = xtable(Timeseries,
caption = paste('Time-series of population estimates
from the', mod1_label, 'base-case.'),
label='tab:Timeseries_mod1',
digits = c(0,0,0,2,2,0,0,2,2))
# Add alignment
align(Timeseries.table) = c('l',
'c',
'>{\\centering}p{.6in}',
'>{\\centering}p{.6in}',
'>{\\centering}p{.6in}',
'>{\\centering}p{.6in}',
'>{\\centering}p{.8in}',
'>{\\centering}p{.8in}',
'c')
# Print timeseries of population estimates table
print(Timeseries.table,
include.rownames = FALSE,
caption.placement = 'top',
tabular.environment = 'longtable',
align=TRUE,
floating = FALSE,
add.to.row = list(pos = list(0),
command = '\\hline \\endhead '))
```
<!-- ---------------------------------------------------------------------- -->
\FloatBarrier
<!-- ***********MODEL 1 HARVEST PROJECTIONS TABLE************************** -->
\newpage
```{r, results = 'asis'}
# Pull OFL contribution and subset years
OFLcatch = mod1$derived_quants[grep('OFLCatch', mod1$derived_quants$Label), ]
OFLcatchyrs = OFLcatch[OFLcatch$Label >= paste('OFLCatch_', Project_firstyr, sep = '') &
OFLcatch$Label <= paste('OFLCatch_', Project_lastyr, sep = ''), ]
# Pull forecasted landings and subset years
ForecastC = mod1$timeseries[, grepl('Yr|retain[(]B[)]', names(mod1$timeseries))]
ForecastC$total = rowSums(ForecastC[, -1])
ForecastCyrs = subset(ForecastC, Yr > (Project_firstyr - 1) & Yr < (Project_lastyr + 1))
# Pull Age 4+ biomass and subset years
Age5biomass = mod1$timeseries[, c('Yr', 'Bio_smry')]
Age5biomassyrs = subset(Age5biomass, Yr > (Project_firstyr - 1) & Yr < (Project_lastyr + 1))
# Pull spawning biomass and subset years
SpawningB = mod1$derived_quants[grep('SPB', mod1$derived_quants$Label), ]
SpawningB = SpawningB[c(-1, -2), ]
SpawningByrs = SpawningB[SpawningB$Label >= paste('SPB_', Project_firstyr, sep = '') &
SpawningB$Label <= paste('SPB_', Project_lastyr, sep = ''), ]
# Pull depletion and subset years
Depletion = mod1$derived_quants[grep('Bratio', mod1$derived_quants$Label), ]
Depletion = Depletion[c(-1, -2), ]
Depletionyrs = Depletion[Depletion$Label >= paste('Bratio_', Project_firstyr, sep = '') &
Depletion$Label <= paste('Bratio_', Project_lastyr, sep = ''), ]
# Combine the data for the forecast table
Forecast_mod1 = as.data.frame(cbind(seq(Project_firstyr, Project_lastyr, 1),
OFLcatchyrs$Value,
ForecastCyrs$total,
Age5biomassyrs$Bio_smry,
SpawningByrs$Value,
Depletionyrs$Value))
# Add column names
colnames(Forecast_mod1)=c('Yr',
'OFL contribution (mt)',
'ACL landings (mt)',
'Age 4+ biomass (mt)',
'Spawning output (trillions of eggs)',
'Relative spawning output')
# Make sure year is a factor, so you don't get decimals
Forecast_mod1$Yr = as.factor(Forecast_mod1$Yr)
# Create the forecast table
Forecast_mod1.table = xtable(Forecast_mod1,
caption = c('Projection of potential
OFL, spawning output, and depletion for the
Northern model.'),
label = 'tab:Forecast_mod1', digits = 2)
# Add alignment
align(Forecast_mod1.table) = c('l',
'c',
'>{\\centering}p{1in}',
'>{\\centering}p{1in}',
'>{\\centering}p{1in}',
'>{\\centering}p{1in}',
'>{\\centering}p{1in}')
# Print model 1 forecast table
print(Forecast_mod1.table,
include.rownames = FALSE,
caption.placement = 'top')
```
<!-- ---------------------------------------------------------------------- -->
\FloatBarrier
<!-- ********************************************************************** -->
<!-- ************************ABLES******************************** -->
<!-- ********************************************************************** -->
\newpage
## Southern Model Tables
<!-- ********************************************************************** -->
<!-- *********************Commercial landings TABLES*********************** -->
<!-- ********************************************************************** -->
```{r, results = 'asis'}
#Southern_catch = read.csv('./txt_files/Southern.Catch.csv')
# colnames(Southern_catch) = c('Year',
# 'Commercial Catch',
# 'Recreational Catch')
# data frame with years from model output
Southern_catch <-
data.frame(Yr = sort(unique(mod2$catch$Yr[mod2$catch$Yr>=mod2$startyr])),
Com = NA,
Rec = NA)
# loop over years to fill in catches
for(irow in 1:nrow(Southern_catch)){
# get year
y <- Southern_catch$Yr[irow]
# get dead biomass for fleet 2 (commercial)
catch <- mod2$catch$kill_bio[mod2$catch$Fleet==2 &
mod2$catch$Yr==y]
Southern_catch$Com[irow] <- round(catch,1)
# get dead biomass for fleet 1 (rec)
catch <- mod2$catch$kill_bio[mod2$catch$Fleet==1 &
mod2$catch$Yr==y]
Southern_catch$Rec[irow] <- round(catch,1)
}
Southern_catch$Total <-
Southern_catch$Rec +
Southern_catch$Com
colnames(Southern_catch) <- c('Year',
'Commercial (mt)',
'Recreational (mt)',
'Total (mt)')
# create table
Southern_catch.table = xtable(Southern_catch,
caption ='Catch timeseries for the Southern model.',
label = 'tab:Southern_catch',
digits = c(0,0,1,1,1))
addtorow <- list()
addtorow$pos <- list()
addtorow$pos[[1]] <- c(0)
addtorow$command <- c(paste("\\hline \n",
"\\endhead \n",
"\\hline \n",
"\\multicolumn{3}{l}",
"{\\footnotesize Continued on next page} \n",
"\\endfoot \n",
"\\endlastfoot \n",sep=""))
# align(Southern_catch.table) = c('l','l',
# 'p{1.0in}',
# 'p{1.0in}',
# 'p{1.0in}')
# align(Southern_catch.table) = c('l','l',
# '>{\\centering}p{0.5in}',
# '>{\\centering}p{0.5in}',
# '>{\\centering}p{0.5in}')
# Print
print(Southern_catch.table,
include.rownames = FALSE,
caption.placement = 'top',
tabular.environment = 'longtable',
floating = FALSE,
add.to.row = addtorow)
```
<!-- ********************************************************************** -->
<!-- *********************Management Performance Table NORTH*************** -->
<!-- ********************************************************************** -->
```{r, results = 'asis'}
#### Management performance table South
mngmnt = read.csv('./txt_files/Exec_mngmt_performance.S.csv')
mngmnt$Catch <- c(round(mod2$sprseries$Dead_Catch_B[mod2$sprseries$Yr %in% 2011:2016],1),
"-","-")
colnames(mngmnt) = c('Year',
'OFL (mt; ABC prior to 2011)',
'ABC (mt)',
'ACL (mt; OY prior to 2011)',
'Estimated total catch (mt)')
# Create the management performance table
mngmnt.table.S = xtable(mngmnt,
caption=c('Southern model recent total catch relative to harvest specifications. The southern stock of yellowtail rockfish has been managed in the Southern Shelf Rockfish complex during this period. The values in this table represent the yellowtail harvest specification contributions to the complex and, as such, are not the reference limits used in managing fisheries catches. There were no harvest specifications for this stock prior to 2011.'),
label='tab:mnmgt_perform.S')
# Add alignment
align(mngmnt.table.S) = c('l',
'>{\\raggedleft}p{1in}',
'>{\\centering}p{1in}',
'>{\\centering}p{1in}',
'>{\\centering}p{1in}',
'>{\\centering}p{1in}')
print(mngmnt.table.S, include.rownames = FALSE, caption.placement = 'top',
sanitize.text.function = function(x){x}, scalebox = .9)
```
\newpage
<!-- ********************************************************************** -->
<!-- *********************Southern Lengths *********************** -->
<!-- ********************************************************************** -->
```{r, results = 'asis'}
Southern_length = read.csv('./txt_files/Southern.Lengths.csv')
colnames(Southern_length) = c('Year',
'Commercial Trawl',
'Tows',
'Hook-and-Line',
'Sites',
'Small Fish',
'MRFSS/RecFIN',
'Onboard')
# Index of abundance summary, create table
Southern_length.table = xtable(Southern_length,
caption ='length timeseries for the Southern model.',
label = 'tab:Southern_length',
digits=3)
addtorow <- list()
addtorow$pos <- list()
addtorow$pos[[1]] <- c(0)
addtorow$command <- c(paste("\\hline \n",
"\\endhead \n",
"\\hline \n",
"\\multicolumn{3}{l}",
"{\\footnotesize Continued on next page} \n",
"\\endfoot \n",
"\\endlastfoot \n",sep=""))
# Print
print(Southern_length.table,
include.rownames = FALSE,
caption.placement = 'top',
tabular.environment = 'longtable',
floating = FALSE,
add.to.row = addtorow)
```
\newpage
<!-- ********************************************************************** -->
<!-- *********************Southern Ages *********************** -->
<!-- ********************************************************************** -->
```{r, results = 'asis'}
Southern_Age = read.csv('./txt_files/Southern.Ages.csv')
colnames(Southern_Age) = c('Year',
'Commercial Trawl',
'Tows',
'Hook-and-Line',
'Sites',
'Small Fish')
# Index of abundance summary, create table
Southern_Age.table = xtable(Southern_Age,
caption ='Age timeseries for the Southern model.',
label = 'tab:Southern_Age',
digits=3)
addtorow <- list()
addtorow$pos <- list()
addtorow$pos[[1]] <- c(0)
addtorow$command <- c(paste("\\hline \n",
"\\endhead \n",
"\\hline \n",
"\\multicolumn{3}{l}",
"{\\footnotesize Continued on next page} \n",
"\\endfoot \n",
"\\endlastfoot \n",sep=""))
# Print
print(Southern_Age.table,
include.rownames = FALSE,
caption.placement = 'top',
tabular.environment = 'longtable',
floating = FALSE,
add.to.row = addtorow)
```