Skip to content

lnk_thresholds: configurable scoring defaults #3

Closed

Description

@NewGraphEnvironment

lnk_thresholds() — configurable scoring defaults

Load, merge, and return severity scoring thresholds as a named list. This is the configuration backbone — every scoring function reads from it.

Signature

lnk_thresholds(
  csv = NULL,
  high = list(outlet_drop = 0.6, slope_length = 120),
  moderate = list(outlet_drop = 0.3),
  low = list()
)

Parameters

All parameters have sane defaults for BC fish passage. Users in other jurisdictions override via csv or named arguments — no code changes needed.

  • csv — path to CSV with columns severity, metric, value. Overrides in-code defaults when provided. Same pattern as frs_params(csv = ...).
  • high, moderate, low — named lists of metric thresholds. Merged with CSV values (CSV wins on conflict).

Returns

Named list keyed by severity level, each containing metric thresholds:

list(
  high = list(outlet_drop = 0.6, slope_length = 120),
  moderate = list(outlet_drop = 0.3),
  low = list()
)

Design intent

  • System-agnostic: metric names are user-defined strings, not hardcoded PSCIS columns
  • Composable: output feeds directly into lnk_score_severity(thresholds = lnk_thresholds(...))
  • Discoverable: ships inst/extdata/thresholds_default.csv so users can see and copy the format
  • Familiar: follows frs_params() pattern — CSV or code, same output shape

Examples must show

  1. Default usage (zero-config BC case)
  2. CSV override for a project with custom thresholds
  3. Inline override for a single metric (lnk_thresholds(high = list(outlet_drop = 0.8)))
  4. How output plugs into lnk_score_severity() — show the integration, not just the function in isolation
  5. The bundled CSV format so users know what to produce

File layout

  • R/lnk_thresholds.R
  • tests/testthat/test-lnk_thresholds.R
  • inst/extdata/thresholds_default.csv

Relates to #1

Activity

  1. NewGraphEnvironment commented on Apr 15, 2026

    @NewGraphEnvironment
    OwnerAuthor

    Built and exported. lnk_thresholds with configurable severity levels, CSV or inline override.

  2. added a commit that references this issue on Apr 24, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions