Package 'rrViewer'

Title: Plotting tools for evaluating Coho run reconstructions
Description: One of the yearly tasks of the FRAM team is to complete the Coho Run Reconstruction. This involves careful evaluation of myriad values in excel files to confirm that they are within reasonable expectations. This package assists in this process by plotting the values of the current run reconstruction across equivalent values in past years.
Authors: Collin Edwards [aut, cre]
Maintainer: Collin Edwards <[email protected]>
License: MIT + file LICENSE
Version: 0.1.0
Built: 2025-02-03 19:21:39 UTC
Source: https://github.com/cbedwards-dfw/rrViewer

Help Index


Provide "stock" and "management_unit_name" options for a run reconstruction dataframe

Description

Once a run reconstruction dataframe is created, it's nice to see the options for stock and management_unit_name identifiers for making plots. This function acts as a wrapper for unique(data$stock) if no stock name is provided; if stock name is provided, instead is a wrapper for filtering to that stock and then ⁠unique(data$management_unit_name⁠. When presenting management unit names, removes astrixes; this is consistent with plot_rr_mu() behavior.

Usage

list_rr_options(data, stock = NULL)

Arguments

data

Dataframe generated by read_rr_trs()

stock

Optional, stock

Value

character vector


Plot timeseries of values for a given management unit.

Description

Plot timeseries of values for a given management unit.

Usage

plot_rr_mu(
  data,
  stock.use,
  mu.use,
  normalize_fisheries = TRUE,
  base_font_size = 13
)

Arguments

data

Dataframe generated from read_rr_trs()

stock.use

Character string of stock name (which identify blocks within the run reconstruction excel file) to plot. Use list_rr_options() to see options.

mu.use

Character string of "management_unit_name" (which identify rows within each block of the run reconstruction excel file) to plot. Use list_rr_options() to see options. Matches versions of management unit name with and without astrices, as those are only used to add notes and should not be treated as new versions of a management unit.

normalize_fisheries

Logical: should the calues of fisheries by turned to % of this stock's catch per fishery in each year (TRUE) or presented as raw values (FALSE). Defaults to TRUE.

base_font_size

Integer passed to theme_bw() to set baseline font size in figures. Defaults to 13.

Value

Figure object made of ggplots combined using {patchwork}.


Read and format run reconstruction

Description

RR sheets are organized into blocks – one left, usually also one right – for each stock. Each block has management units for rows and fisheries for columns, with some summary columns and some summary rows. This function translates those into longform; see details. This function is designed to be robust to the addition or subtraction of rows or columns within blocks, and additions of new blocks that have "Return Year" in the second column, first row and "Wild" in the final row, first column. However, changes in the number of columns between the left and right blocks (e.g., shifting the black separator column from N to something else) will break this function. However, it appears that this is typically addressed by creating a "continued" block for blocks that would exceed the number of columns. The combine_continued argument controls handling of these blocks.

Usage

read_rr_trs(path, combine_continued = TRUE)

Arguments

path

Run reconstruction file

combine_continued

Logical: Should "continued" type blocks be combined? Defaults to TRUE.

Details

To translate each block into compatible longform dataframes, we add several identifiers. ⁠$stock⁠ identifies which stock is in use, year and sheetname identify which datasheet the data comes from, block identifies whether the data comes from the right or left blocks, and then management_unit_name and col_name identify the row and column identifiers from within each block. Because the columns for right-hand blocks sometimes include super-columns (e.g., "Stillaguamish/Snohomish" has "Aggregate Totals", "Stillaguamish Origin", and Snohomish Origin"). col_name_super identifies these. This is given it's own block and stock value.

We also have have a specieal block for "Ar 13D Net CWT..." in columns P-Q.

Value

tibble of run reconstruction in long form. See details.

Examples

## Not run: 
rr.dat <- read_rr_trs("/Copy of PScohoRR_TRS_2010-2023_2023-01-22 _draft.xlsx")

## End(Not run)