Skip to contents

Connecting to FRAM database

Functions to connect to and disconnect from a FRAM database

connect_fram_db()
Connect to FRAM database
disconnect_fram_db()
Safely disconnect from FRAM database
list_extant_fram_connections()
Describe existing fram connections (including orphans)
disconnect_all_fram_connections()
Clear all connections

Importing FRAM tables

Functions to import a FRAM database table into R

fetch_table()
Fetch a complete table from a FRAM database.
fetch_table_bkchin()
Safely fetch Chinook BackwardsFRAM table

FRAM filtering

Functions to filter FRAM tables by fishery

filter_ak()
Filters a dataframe to Alaska fisheries. Will automatically detect whether it's working with a Chinook or Coho dataset if the tables were generated within this package. .data must have a fishery_id column name.
filter_bc()
Filters a dataframe to Canadian (BC) fisheries. Will automatically detect whether it's working with a Chinook or Coho dataset if the tables were generated within this package. .data must have a fishery_id column name.
filter_ca()
Filters a dataframe to California fisheries. Will automatically detect whether it's working with a Chinook or Coho dataset if the tables were generated within this package. .data must have a fishery_id column name.
filter_coast()
Filters a dataframe to Coastal fisheries. Will automatically detect whether it's working with a Chinook or Coho dataset if the tables were generated within this package. .data must have a fishery_id column name.
filter_commercial_wa_nt()
Filters a dataframe to WA non-treaty commercial fisheries. Will automatically detect whether it's working with a Chinook or Coho dataset if the tables were generated within this package. .data must have a fishery_id column name.
filter_flag()
NA's all the information in the FisheryScalers that's not being used e.g Flag 1 only NS Scalers will be returned
filter_marine()
Filters a dataframe to marine fisheries. Will automatically detect whether it's working with a Chinook or Coho dataset if the tables were generated within this package. .data must have a fishery_id column name.
filter_net()
Filters a dataframe to net fisheries. Will automatically detect whether it's working with a Chinook or Coho dataset if the tables were generated within this package. .data must have a fishery_id column name.
filter_or()
Filters a dataframe to Oregon fisheries. Will automatically detect whether it's working with a Chinook or Coho dataset if the tables were generated within this package. .data must have a fishery_id column name.
filter_puget_sound()
Filters a dataframe to Puget Sound fisheries. Will automatically detect whether it's working with a Chinook or Coho dataset if the tables were generated within this package. .data must have a fishery_id column name.
filter_sport()
Filters a dataframe to sport fisheries. Will automatically detect whether it's working with a Chinook or Coho dataset if the tables were generated within this package. .data must have a fishery_id column name.
filter_wa()
Filters a dataframe to Washington State fisheries. Will automatically detect whether it's working with a Chinook or Coho dataset if the tables were generated within this package. .data must have a fishery_id column name.

Comparing FRAM runs

Functions that compare two FRAM runs within the same database

compare_databases()
[Experimental] Compare tables in two equivalent FRAM databases
compare_fishery_input_flags()
Compares the fishery flags of two runs
compare_fishery_inputs()
Compares the fishery inputs of two runs
compare_inputs()
Generates a dataframe that compares fishery scalers table for two runs identified by run_id's
compare_inputs_chart()
Generate heat map of changed values between two run inputs.
compare_non_retention_input_flags()
Compares the non retention flags of two runs
compare_non_retention_inputs()
Compares the non retention inputs of two runs
compare_recruits()
Compares the recruit scalers of two runs
compare_runs()
Generates a report to the console of changes to inputs between two runs
compare_stock_fishery_rate_scalers()
Compares the stock fishery rate scalers of two runs

FRAM Screen Reports

Functions that replicate FRAM UI screen reports

msf_encounters()
Reproduce MSF encounters screen
msf_encounters_chinook_()
Replicate MSF screen report encounters for Chinook
msf_encounters_coho_()
Replicate MSF screen report encounters for COHO
msf_landed_catch()
Reproduce MSF landed catch screen
msf_landed_catch_chinook_()
Replicate MSF screen report landed catch for Chinook
msf_landed_catch_coho_()
Replicate MSF screen report landed catch for COHO
msf_mortalities()
Reproduce MSF mortalities screen
msf_mortalities_chinook_()
Replicate MSF screen report mortalities for Chinook
msf_mortalities_coho_()
Replicate MSF screen report mortalities for COHO
population_statistics()
Replicate Population Statistics screen
fishery_mortality()
Returns a tibble matching the Fishery Mortality screen.
stock_mortality()
Replicate Stock Mortality screen

Stock impact visualizations

Functions that visualize impacts of stocks in fisheries

plot_impacts_per_catch_heatmap()
Make plots to show the amount of landed catch_per_impact
plot_stock_comp()
Plot stock composition
plot_stock_mortality()
Plot total mortalities by fishery
plot_stock_mortality_time_step()
Creates an ordered bar chart with the top number of mortalities per fishery and time step.

Initializing R FRAM Projects

Creates a standardized workspace for fram related R projects

initialize_project()
[Experimental] Initializes a FRAM project
fetch_quarto_templates()
Creates quarto template files

Database altering functions

Functions that alter FRAM database tables, use with caution

copy_fishery_scalers()
Experimental copying scaler inputs from one run to another DANGEROUS
copy_run()
[Experimental] Copies a run a number of times
copy_tamms()
[Experimental] Copy TAMM for FRAM batch runs
change_run_id()
Changes a run's ID number in a FRAM database
remove_run()
Removes a run in a FRAM database
modify_table()
[Experimental] Modify FRAM database based on match/replace dataframe
make_batch_runs()
Make batch runs

Sensitivity analysis functions

Functions that create new FRAM database tables to align with a sensitivity analysis, use with caution

sensitivity_custom()
[Experimental] Generate sensitivity analyses runs based on a list of match/replace dataframes
sensitivity_exact()
[Experimental] Generate sensitivity analyses runs based on exact values
sensitivity_scaled()
[Experimental] Generate sensitivity analyses runs scaled by template values
calc_fram_scaling()
[Experimental] Calculate match/replace df based on scaling

Week calculations

Functions calculate a week number

management_week()
Vectorized approach to calculating the management week, returns an integer
statistical_week()
Vectorized approach to calculating the statistical week, returns an integer

Validations

Functions that validate FRAM data

validate_fishery_ids()
Convenience function to check fishery input
validate_fram_db()
Convenience function to check fram_db input
validate_run_id()
Convenience function to check run_id input
validate_stock_ids()
Convenience function to check fishery input

Terminal Runs

Functions that unpack the TRuns table in the FRAM database

truns_fisheries()
Returns a dataframe with fisheries defined by the TRuns report driver
truns_stocks()
Returns a dataframe with stocks defined by the TRuns report driver

Post-season FRAM

Functions that focus on post-season runs and backwards FRAM

bkfram_checks_coho()
Performs error checks of a backwards FRAM run Returns nested tibble with diagnostics
post_season_abundance()
Generates post-season January age 3 abundances by stock from post-season databases. Used for forecasting.

Describing the FRAM Database

Functions that describe the current FRAM database

fram_clean_tables()
Cleans the names of FRAM tables and coverts to a tibble
fram_database_species()
Identifies the FRAM database species focus - Chinook or Coho
fram_database_type()
Identifies the FRAM database type - Full or Transfer
get_run_ids()
Gets all run_ids of FRAM database
find_tables_by_column_()
Finds tables that contain a specific column name
provide_table_names()
List names of FRAM table
run_info()
Provides a print out of Run ID information

Data checking

Functions that provide checks for the current data

addstock_check()
Check FRAM database after adding new stock
bkfram_checks_coho()
Performs error checks of a backwards FRAM run Returns nested tibble with diagnostics
check_demo_coverage()
Check if exported functions are documented in a file
stock_age_checker()
Helper function to check that all stock x age combinations are present
stock_check_helper()
Helper function to check that stock id make sense
frs_stylecheck_assignment() frs_stylecheck_snakecase()
Framrsquared style guide

Stock summaries

Functions that describe the fate of a stock

stock_fate() experimental
[Experimental] Summarizes the three true outcomes of a stocks abundance, where it dies to fishery related mortality, natural mortality, or reaches some sort of escapement. When run against the coho database spawning escapement will be displayed, when run against the Chinook database escapement to the river will be dislpayed along with recruits to the next year 'age_up'
stock_fate_chinook() experimental
[Experimental] Chinook flavor of the stock fate function
stock_fate_coho() experimental
[Experimental] Coho flavor of the stock fate function

Describing Terminal Run Information

Functions that unpack the TAAETRS tables

terminal_fisheries()
[Experimental] List terminal stock information
terminal_stocks()
[Experimental] List terminal stock information
terminal_info()
[Experimental] Parse TAAETRS table

Labeling

Functions that add label columns based on ids or flags

label_fisheries_db()
Label fisheries based on FRAM database
label_flags()
Adds a column with a text version of flags for either non-retention or fishery scalers
label_stocks_db()
Label stocks based on FRAM database

Misc.

Miscellaneous functions

add_total_mortality()
Sum separate mortality columns into new "total_mortality" column
cohort_abundance()
[Experimental] Calculate starting cohort abundance
aeq_mortality()
Extract AEQ mortality from Chinook FRAM database. Refactored and stripped down from the framr package written by Dan Auerbach. https://github.com/FRAMverse/framr/
coho_mark_rates() experimental
[Experimental] Returns a tibble displaying predicted FRAMencounter mark rates by fishery, fishery type, and time-step.
input_summary_()
Generates an input summary based on a FisheryScalers dataframe. Probably end up streamlining / revising this.
mortality_scalers()
Quantify the proportion of fishery mortalities associated with stock(s) of interest
msp_mortality()
Expand Chinook mortality table using Model-Stock Proportion
NR_flag_translate()
Provides English translation of numeric non-retention flags
scalers_flag_translate()
Provides English translation of numeric scalers flags
stock_id_comp()
Helper function to check that stock id exist in the Stock database
provide_table_names()
List names of FRAM table
welcome()
Welcome message, summarizing database information

Get ids

Functions to extract ids for runs, stocks, fisheries

get_run_ids()
Gets all run_ids of FRAM database
get_fishery_ids()
Gets all fishery_ids of FRAM database
get_stock_ids()
Gets all stock_id of FRAM database