Skip to contents

This function validates the price per kilogram of catch data by comparing it to calculated upper and lower bounds from the get_pricekg_bounds function. If a price value is outside the bounds, an alert is triggered and the price, catch weight, and total catch price values are set to NA.

Usage

validate_pricekg(data = NULL, k = NULL)

Arguments

data

A data frame containing catch data with columns: form_name, survey_id, catch_taxon, price_kg, catch_price, and catch_kg.

k

A numeric value used in the get_pricekg_bounds function for outlier detection.

Value

A data frame with columns:

  • form_name: The name of the form associated with the survey

  • survey_id: The unique identifier for each survey

  • price_kg: The original price per kg if valid, otherwise NA

  • catch_kg: The original catch weight if price is valid, otherwise NA

  • catch_price: The original total catch price if price per kg is valid, otherwise NA

  • alert_price: A numeric value (4) indicating an outlier, or NA if the value is valid

Details

The function first calculates price bounds using get_pricekg_bounds(). It then joins these bounds with the input data and compares each price_kg value to its corresponding upper and lower bounds. If the price_kg value is outside the bounds, an alert is set and the price_kg, catch_kg, and catch_price values are changed to NA.