
Validate Consistency Between Diet and Energy Data
Source:R/11.3-data-validators.R
validate_diet_consistency.RdValidates consistency between diet composition and prey energy density data, ensuring they have matching prey species and valid values.
Value
Invisibly returns TRUE if all checks pass. Throws an error
if prey columns differ between the two data frames, if any diet
proportion is negative, or if any prey energy is non-positive. Issues a
warning when diet row sums deviate from 1.0 by more than 0.1 or when
prey energies fall outside the typical 500–25000 J/g range.
Details
Validation includes:
Matching prey species columns between datasets
Diet proportions sum approximately to 1.0
No negative diet proportions
All prey energies are positive
Examples
diet <- data.frame(Day = 1:5, fish = 0.6, zooplankton = 0.4)
energy <- data.frame(Day = 1:5, fish = 4000, zooplankton = 2500)
isTRUE(validate_diet_consistency(diet, energy))
#> [1] TRUE