Validate Catch Price per Kilogram
validate_pricekg.Rd
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.
Value
A data frame with columns:
form_name
: The name of the form associated with the surveysurvey_id
: The unique identifier for each surveyprice_kg
: The original price per kg if valid, otherwise NAcatch_kg
: The original catch weight if price is valid, otherwise NAcatch_price
: The original total catch price if price per kg is valid, otherwise NAalert_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.