
Calculate non-nutritive visits per animal per day
Source:R/non_nutritive_visits.R
calculate_non_nutritive_visits.Rd
Calculates the number of non-nutritive visits for each animal on each day. A non-nutritive visit occurs when an animal visits a bin that has feed available (more than the calibration error) but does not eat anything.
Usage
calculate_non_nutritive_visits(
data,
cfg = qc_config(),
id_col = id_col2(),
intake_col = intake_col2(),
start_weight_col = start_weight_col2()
)
Arguments
- data
A named list of daily data frames (one per day), each containing visit-level data.
- cfg
A configuration list created by
qc_config()
.- id_col
Animal ID column name (default current global value from
id_col2()
)- intake_col
Intake column name (default current global value from
intake_col2()
)- start_weight_col
Start weight column name (default current global value from
start_weight_col2()
)
Value
A named list of data frames, one per day, each containing columns for animal ID and the count of non-nutritive visits.
Examples
toy_data <- list(
"2023-01-01" = data.frame(
cow = c("1", "2", "3", "1"),
intake = c(0.2, 0.3, 0.4, 0.0),
start_weight = c(10, 15, 20, 12)
)
)
cfg <- qc_config(calibration_error = 0.5)
result <- calculate_non_nutritive_visits(toy_data, cfg = cfg)
result[[1]]
#> # A tibble: 3 × 2
#> cow number_of_non_nutritive_visits
#> <chr> <int>
#> 1 1 2
#> 2 2 1
#> 3 3 1