Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added warning message to fetch_table, added fetch_table_bkchin() #56

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

cbedwards-dfw
Copy link
Contributor

@cbedwards-dfw cbedwards-dfw commented Dec 13, 2024

Address #48

BackwardsFRAM table in chinook databases has a stock_id field that uses a different numbering system than the stock_id field in all other chinook tables.

This means that, for example joining fetch_table(fram.db, table_name = "BackwardsFRAM") and fetch_table(fram.db, table_name = "Cohort") will silently produce a meaningless result when working with a Chinook database.

To prevent this, this branch

  1. Adds a CLI warning specifically when fetching the BackwardsFRAM table from a Chinook database. Warning behavior can be toggled with new optional warn argument.
  2. adds fetch_table_bkchin(), which uses fetch_table() but then renames the problematic stock_id column to bk_stock_id, and then uses the chinook bkfram lookup table in {framrosetta} to add in a functional stock_id column and the names associated with the bkfram stocks.

Example comparison:

fram.db = connect_fram_db("2024 Pre-Season Chinook DB.mdb")
tab1 = fetch_table(fram.db, table_name = "BackwardsFRAM") |> 
  dplyr::left_join(fetch_table(fram.db, table_name = "Cohort"))
## tab1 has meaningless matching between the Cohort table and BackwardsFRAM table
## due to the non-synonymous stock_id column

tab2 = fetch_table_bkchin(fram.db)  |> 
  dplyr::left_join(fetch_table(fram.db, table_name = "Cohort"))
## tab2 has the correct matching

disconnect_fram_db(fram.db)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant