From d161d909a6a268b93a9b6efa54f1ad43d769bf64 Mon Sep 17 00:00:00 2001 From: okenk Date: Thu, 7 Nov 2024 17:18:33 -0800 Subject: [PATCH] data summary quarto doc --- .gitignore | 20 +- R/data_summary_doc.html | 1486 +++++++++++++++++++++++++++++++++++++++ R/data_summary_doc.qmd | 129 ++++ 3 files changed, 1619 insertions(+), 16 deletions(-) create mode 100644 R/data_summary_doc.html create mode 100644 R/data_summary_doc.qmd diff --git a/.gitignore b/.gitignore index 24c59fb..2eb6488 100644 --- a/.gitignore +++ b/.gitignore @@ -1,55 +1,42 @@ # History files .Rhistory .Rapp.history - # Session Data files .RData .RDataTmp - # User-specific files .Ruserdata - # Example code in package build process *-Ex.R - # Output files from R CMD build /*.tar.gz - # Output files from R CMD check /*.Rcheck/ - # RStudio files .Rproj.user/ - # produced vignettes vignettes/*.html vignettes/*.pdf - # OAuth2 token, see https://github.com/hadley/httr/releases/tag/v0.3 .httr-oauth - # knitr and R markdown default cache directories *_cache/ /cache/ - +*_files/ # Temporary files created by R markdown *.utf8.md *.knit.md - # R Environment Variables .Renviron - # pkgdown site docs/ - # translation temp files po/*~ - # RStudio Connect folder rsconnect/ - -# Confidential data +# Confidential and/or large data files Data/Confidential +Data/Raw_not_confidential # SS3 files admodel.cov @@ -89,3 +76,4 @@ ss3.std ss.par_1.sso suggested_tuning.ss *.ss_new +YTRK_2017_Final.pdf diff --git a/R/data_summary_doc.html b/R/data_summary_doc.html new file mode 100644 index 0000000..cc65977 --- /dev/null +++ b/R/data_summary_doc.html @@ -0,0 +1,1486 @@ + + + + + + + + + +Data summary + + + + + + + + + + + + + + + + + + + +
+ +
+ +
+
+

Data summary

+
+ + + +
+ + + + +
+ + +
+ +
+

Commercial landings

+
+
+

+
+
+
+

Washington

+
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
LANDING_YEARcatch_mt
19815128.3
19825769.3
19835326.6
19842311.8
19851347.0
19861982.7
19871876.9
19882943.5
19891689.3
19901639.7
19911140.8
19921327.4
19932014.4
19941898.8
19951482.6
19961451.4
1997476.5
1998616.9
1999563.3
2000877.6
2001756.3
2002659.9
2003358.1
2004467.3
2005651.0
2006280.3
2007220.3
2008262.4
2009506.3
2010664.6
2011601.1
2012924.1
2013538.3
2014442.0
2015528.3
2016417.2
2017790.0
20181026.3
20191070.2
20201141.6
2021986.9
2022783.3
2023893.5
+
+
+

WDFW has alerted the STAT these do not include all tribal catches in recent years. Tribal catches are:

+
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
LANDING_YEARcatch_mt
198411.0
19870.7
19880.9
19890.1
19901.8
19911.6
19920.3
19933.5
19944.3
19950.2
19960.6
19971.1
19986.2
199916.0
200035.4
200198.7
2002259.9
2003273.0
2004352.9
2005542.1
2006171.9
200776.1
2008223.3
2009451.3
2010539.4
2011440.5
2012511.6
2013392.0
2014198.5
2015385.0
2016244.5
2017244.3
2018123.3
2019112.9
202014.5
202147.1
202215.0
20239.6
+
+
+
+
+

Oregon

+

These were provided directly to the STAT

+
+
+

California

+
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
LANDING_YEARcatch_mt
198194.4
1982331.4
1983105.3
1984357.7
1985120.2
1986268.9
1987141.6
1988144.5
1989353.9
1990466.4
1991405.8
1992231.8
1993102.3
1994104.6
1995115.9
1996153.2
199789.6
1998132.6
199960.9
200021.0
200141.2
200216.0
20031.0
20043.7
20050.8
20060.8
20071.4
20081.7
20090.6
20100.2
20110.3
20120.3
20130.8
20140.7
20154.3
20161.3
20174.0
201811.0
201911.2
202014.0
202128.1
202219.2
202320.7
+
+
+

Note this is for catch landed into Del Norte and Humboldt counties only.

+
+
+
+

Recreational landings

+
+

Washington

+

Modern catches:

+
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
RECFIN_YEARDead_Catch_mt
199013.5
199131.8
199232.9
199341.7
199419.3
199514.3
199620.4
199724.5
199841.6
199914.4
200018.1
200111.7
20023.2
200311.2
200417.4
200514.0
20068.8
200714.1
200813.8
200928.3
201042.9
201153.2
201218.6
201323.2
201442.3
201526.0
201636.6
201747.3
201838.1
201948.4
202059.9
202161.5
202268.6
+
+
+

Questions:

+
    +
  1. There are three values for RECFIN_WATER_AREA_NAME: Estuary, Ocean, and Canada. Which should be included? Above table excludes Canada.
  2. +
  3. 2023 has a number of instances where RECFIN_WEEK is zero, and one instance where is it missing. In the instance where it is missing, there is no estimate of catch in mt.
  4. +
+

Historical catches:

+
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
RECFIN_YEARDead_Catch_num
196738119
197522918
197631634
197722340
197819513
197914676
198016954
198112535
19827244
198312142
19846102
19855292
198616273
19878141
19887311
19896639
+
+
+
+
+

Oregon

+

These were provided directly to the STAT

+
+
+

California

+
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
RECFIN_YEARDead_Catch_mt
20050.2
20060.2
20070.5
20080.3
20091.0
20100.3
20110.5
20120.7
20130.7
20140.3
20150.6
20160.2
20170.5
20181.0
20191.3
20200.5
20211.1
20221.2
20233.1
+
+
+

Note that 2020 proxy catches are missing, and we will need historical recreational catches that are not on RecFIN.

+
+
+
+

Commercial length data

+

Initial sample sizes after running PacFIN.Utilities::cleanPacFIN():

+
+
+
  AGE_METHOD1 AGE_METHOD2 AGE_METHOD3 Age method for best age      n
+1           B           B           B                       B   2346
+2           B           B        <NA>                              1
+3           B           B        <NA>                       B   4373
+4           B        <NA>        <NA>                             32
+5           B        <NA>        <NA>                       B 134303
+6           L        <NA>        <NA>                       L      3
+7           S        <NA>        <NA>                       S  17942
+8           T        <NA>        <NA>                       T      2
+9        <NA>        <NA>        <NA>                    <NA>  70424
+
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
yearCAORWA
1968001225
1969001852
197000981
1971001087
1972001252
197300697
197400350
197500458
1976002776
197700778
197813201876
19794101599
19807403705
1981616073900
198218414993496
19832781992366
198470410983200
198526121043500
198618111562992
198714518912046
19883716701650
198923020551650
199019218021875
199126512961950
199273724901700
199326120221800
199484726413562
199543622423505
199666022593154
199727740922501
199861832352105
199935035782195
200014130052283
200120428322045
200210515381663
2003417011629
20046413411783
2005679801173
20061001251968
200710611962515
2008415851841
2009608551450
2010216181614
20117218161415
201213119152231
201320312691275
201421918981309
201519623931760
201619931451587
201738330402470
201835929501651
201933427821146
20201681932551
202160318151157
202218424431469
2023021451415
+
+
+

Note that California lengths are not available for 2023.

+

While running PacFIN.Utilities::cleanPacFIN(), it noted that 20 Washington ages in 1991 were double read, the second reader was not recorded, the first and second ages differed, and no final age was determined.

+
+ +
+ + +
+ + + + \ No newline at end of file diff --git a/R/data_summary_doc.qmd b/R/data_summary_doc.qmd new file mode 100644 index 0000000..85a5cab --- /dev/null +++ b/R/data_summary_doc.qmd @@ -0,0 +1,129 @@ +--- +title: "Data summary" +format: + html: + toc: true +editor: visual +--- +```{r opts, echo = FALSE, include = FALSE, warning = FALSE, message = FALSE} +knitr::opts_chunk$set(echo = FALSE, warning = FALSE, message = FALSE) +library(here) +library(dplyr) +library(ggplot2) +``` + +## Commercial landings +```{r, cache=TRUE} +load(here('data/confidential/PacFIN.YTRK.CompFT.09.Oct.2024.RData')) + +yt.n.catch <- catch.pacfin |> + filter( + AGENCY_CODE == 'W' | AGENCY_CODE == 'O' | COUNTY_NAME == 'DEL NORTE' | COUNTY_NAME == 'HUMBOLDT', + LANDING_YEAR < 2024 + ) + +yt.n.catch |> + group_by(AGENCY_CODE, LANDING_YEAR) |> + summarise(catch_mt = sum(LANDED_WEIGHT_MTONS)) |> + ggplot() + + geom_col(aes(x = LANDING_YEAR, y = catch_mt, fill = AGENCY_CODE)) + + ggtitle('Commercial landings through 2023') + +``` + +### Washington +```{r} +filter(yt.n.catch, AGENCY_CODE == 'W') |> + group_by(LANDING_YEAR) |> + summarise(catch_mt = sum(LANDED_WEIGHT_MTONS)) |> + knitr::kable(align = 'l', digits = 1) +``` + +WDFW has alerted the STAT these do not include all tribal catches in recent years. Tribal catches are: +```{r} +filter(yt.n.catch, AGENCY_CODE == 'W', PARTICIPATION_GROUP_NAME == "TREATY INDIAN COMMERCIAL FISHER") |> + group_by(LANDING_YEAR) |> + summarise(catch_mt = sum(LANDED_WEIGHT_MTONS)) |> + knitr::kable(align = 'l', digits = 1) +``` + + +### Oregon +These were provided directly to the STAT + +### California +```{r} +filter(yt.n.catch, AGENCY_CODE == 'C') |> + group_by(LANDING_YEAR) |> + summarise(catch_mt = sum(LANDED_WEIGHT_MTONS)) |> + knitr::kable(align = 'l', digits = 1) +``` + +Note this is for catch landed into Del Norte and Humboldt counties only. + +## Recreational landings + +### Washington + +Modern catches: +```{r} +wa_modern <- readr::read_csv(here('Data/Raw_not_confidential/RecFIN_WA_catch_to_2023.csv')) |> + filter(RECFIN_WATER_AREA_NAME != 'Canada', RECFIN_YEAR < 2023) +wa_modern |> group_by(RECFIN_YEAR) |> + summarise(Dead_Catch_mt = sum(SUM_TOTAL_MORTALITY_MT)) |> + knitr::kable(align = 'l', digits = 1) +``` + + +Questions: + +1. There are three values for `RECFIN_WATER_AREA_NAME`: Estuary, Ocean, and Canada. Which should be included? Above table excludes Canada. +2. 2023 has a number of instances where `RECFIN_WEEK` is zero, and one instance where is it missing. In the instance where it is missing, there is no estimate of catch in mt. + +Historical catches: +```{r} +wa_historical <- readr::read_csv(here('Data/Raw_not_confidential/WA_historical_rec.csv')) + +wa_historical |> + group_by(RECFIN_YEAR) |> + summarise(Dead_Catch_num = sum(RETAINED_NUM)) |> + knitr::kable(align = 'l', digits = 1) +``` +### Oregon +These were provided directly to the STAT + +### California +```{r} +ca_modern <- readr::read_csv(here('Data/Raw_not_confidential/RecFIN_CA_catch_to_2023.csv')) |> + filter(DISTRICT_NAME == "Redwood (Humboldt County, Except Shelter Cover Area, And Del Norte County)" ) +ca_modern |> + group_by(RECFIN_YEAR) |> + summarise(Dead_Catch_mt = sum(SUM_TOTAL_MORTALITY_MT)) |> + knitr::kable(align = 'l', digits = 1) + + +``` +Note that 2020 proxy catches are missing, and we will need historical recreational catches that are not on RecFIN. + +## Commercial length data + +Initial sample sizes after running `PacFIN.Utilities::cleanPacFIN()`: +```{r, cache=TRUE} +load(here('Data/Confidential/PacFIN.YTRK.bds.09.Oct.2024.RData')) +bds.clean <- bds.pacfin |> + filter(AGENCY_CODE == 'W' | AGENCY_CODE == 'O' | PACFIN_GROUP_PORT_CODE == 'CCA' | + PACFIN_GROUP_PORT_CODE == 'ERA') |> + PacFIN.Utilities::cleanPacFIN(verbose = FALSE) + +bds.clean |> + filter(year < 2024) |> + group_by(state, year) |> + summarise(n_length = sum(!is.na(length))) |> + tidyr::pivot_wider(names_from = state, values_from = n_length, values_fill = 0) |> + arrange(year) |> + knitr::kable(align = 'l', digits = 1) + +``` +Note that California lengths are not yet available for 2023. + +While running `PacFIN.Utilities::cleanPacFIN()`, it noted that 20 Washington ages in 1991 were double read, the second reader was not recorded, the first and second ages differed, and no final age was determined. \ No newline at end of file