Skip to contents

Connecting to FRAM database

Functions to connect a disconnect to a FRAM database

connect_fram_db()
This is a connection object to a FRAM database. Returns a list used throughout the rest of this package which carries meta data.
disconnect_fram_db()
Safely disconnect from FRAM database

Importing FRAM tables

Functions to import a FRAM database table into R

fetch_table()
Fetches a complete table from a FRAM database. Returns a cleaned tibble.
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. Requires 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. Requires 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. Requires 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. Requires 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. Requires 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. Requires 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. Requires 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. Requires 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. Requires 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. Requires a fishery_id column name.

Comparing FRAM runs

Functions that compare two FRAM runs within the same database

compare_databases()
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()
Generates a heat map of changed between two run inputs. Can be a very busy chart if not filtered down. Consider using a filter.
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()
Produces the MSF screen report numbers for encounters. Returns different format depending database.
msf_encounters_chinook_()
Returns a tibble matching the MSF screen report encounters for Chinook. This is specific for Chinook and in most cases msf_encounters() is preferable.
msf_encounters_coho_()
Returns a tibble matching the MSF screen report encounters for Coho This is specific for Coho and in most cases msf_encounters() is preferable.
msf_landed_catch()
Produces the MSF screen report numbers for landed catch. Returns different format depending database.
msf_landed_catch_chinook_()
Returns a tibble matching the MSF screen report landed catch for Chinook. This is specific for Chinook and in most cases msf_landed_catch() is preferable.
msf_landed_catch_coho_()
Returns a tibble matching the MSF screen report landed catch for Coho This is specific for Coho and in most cases msf_landed_catch() is preferable.
msf_mortalities()
Produces the MSF screen report numbers for mortalities. Returns different format depending database.
msf_mortalities_chinook_()
Returns a tibble matching the MSF screen report mortalities for Chinook. This is specific for Chinook and in most cases msf_mortalities() is preferable.
msf_mortalities_coho_()
Returns a tibble matching the MSF screen report mortalities for Coho This is specific for Coho and in most cases msf_mortalities() is preferable.
population_statistics()
Returns a tibble matching the Population Statistics screen.
fishery_mortality()
Returns a tibble matching the Fishery Mortality screen.
stock_mortality()
Returns a tibble matching the Fishery Mortality screen.

Stock impact visualizations

Functions that visualize impacts of stocks in fisheries

plot_stock_mortality()
Creates an ordered bar chart with the top number of mortalities per fishery.
plot_stock_mortality_time_step()
Creates an ordered bar chart with the top number of mortalities per fishery and time step.
make_impacts_per_catch_heatmap()
Make plots to show the amount of landed catch_per_impact

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
change_run_id()
Changes a run's ID number in a FRAM database
remove_run()
Removes a run in a FRAM database

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_fram_db()
Convenience function to check fram_db input
validate_run_id()
Convenience function to check run_id 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
error_check_code()
Check code for common errors
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

Misc.

Miscellaneous functions

add_flag_text()
Adds a column with a text version of flags for either non-retention or fishery scalers
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()
Guestimate the impact on a particular stock by multiplying its mortalities by the stock_mortality_ratio produced by these functions.
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
welcome()
Welcome message, summarizing database information