Learn R Programming

fb4package (version 2.0.0)

validate_diet_consistency: Validate Consistency Between Diet and Energy Data

Description

Validates consistency between diet composition and prey energy density data, ensuring they have matching prey species and valid values.

Usage

validate_diet_consistency(diet_data, energy_data)

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.

Arguments

diet_data

Data frame with diet proportions

energy_data

Data frame with prey energies

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

Run this code
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))

Run the code above in your browser using DataLab