View source: R/11.3-data-validators.R
| validate_diet_consistency | R Documentation |
Validates consistency between diet composition and prey energy density data, ensuring they have matching prey species and valid values.
validate_diet_consistency(diet_data, energy_data)
diet_data |
Data frame with diet proportions |
energy_data |
Data frame with prey energies |
Validation includes:
Matching prey species columns between datasets
Diet proportions sum approximately to 1.0
No negative diet proportions
All prey energies are positive
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.
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))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.