Skip to contents

Getting Started

Core functions for reading and processing data.

read_data_safely()
Safely Read Data from a File
process_all_feed()
Process a batch of feeder files
process_all_water()
Process a batch of water files
process_feeder()
Process 1 feeder data file
process_water()
Process 1 water data file

Data Cleaning and Preparation

Data Quality Checks

Check and validate feeding and drinking visits.

qc_config()
Build a configuration list for data quality-control
qc()
Run full quality-control check on feeder and drinker data
knn_outlier_detection()
Detect outliers using k-nearest neighbors (KNN) method
knn_clean_feed()
Process multiple days of feeding data and remove outliers using KNN
knn_clean_water()
Process multiple days of water data and remove outliers using KNN
viz_outliers()
Visualize outliers from KNN outlier detection

Data Filtering

Filter data relevant to animals and sensors in your study.

delete_rows()
Remove rows by matching values in a specified column
keep_bins()
Keep only rows for specified bins
rename_bins()
Shift specified bin IDs by an offset

Time Adjustments

Handle Daylight Saving Time changes for North America.

daylight_saving_adjust()
Adjust Time Stamp for Daylight Saving Time (DST) Transitions in North America
get_dst_switch_info()
Get Daylight Saving Time (DST) Switch Dates and Exact Transition Times
dst_switch_day()
Detect Daylight Saving Time (DST) Change Dates
dst_switch_hm()
Detect the Exact Time (hour and minute; hm) of Daylight Saving Time (DST) Change

File Management

Extract date information from file names and compare files.

file_name_processing()
Process file names and extract date tokens
compare_files()
Compare feed and water file names by shared dates
get_date_range()
Get the overall date range for a set of files
cap_first()
Capitalize the First Letter of a String
lower_first()
De-capitalize the First Letter of a String to Lower Case

Data Integration

Merge and unmerge feeding and drinking data

combine_feed_water()
Combine Feeder and Water Data by Date
merge_list_df()
Merge a List of Data Frames
unmerge_data()
Un-merge a combined data frame into a list of data frames by date

Story of Every Cow

Feed and Water Summary

Summarize daily feed/water intake, duration, and visit counts.

feed_water_summary()
Summarize and check for abnormal feed & water intake

Bin visit summary

Analyze bin visit patterns.

unique_bin_visits()
Analyze Bin Visit Patterns For Each Cow

Non-nutritive Visit Analysis

Functions for analyzing non-nutritive and no-feed visits per animal per day.

calculate_non_nutritive_visits()
Calculate non-nutritive visits per animal per day
calculate_no_feed_visits()
Calculate visits with no feed available per animal per day

Replacement Behavior Analysis

Functions to identify replacement behavior across multiple days, and validate those events by checking whether the actor cow was already present at another bin.

record_replacement_days()
Identify and validate replacement events across multiple days

Meal clustering

Cluster feeding visits into meals.

meal_interval()
Calculate optimal interval between feeding visits for meal clustering
viz_eps_percentile()
Visualize gap distribution and percentile-based optimal interval (eps) selection
viz_eps_gmm()
Visualize gap distribution with GMM fit and optimal interval (eps)
cluster_meals()
Cluster feeding visits into meals using DBSCAN
meal_label_visits()
Cluster feeding visits into meals and label each visit
merge_cluster_results()
Merge meal clustering results with original visit data
viz_meal_clusters()
Visualize meal clustering results as timeline plots
combine_animal_plots()
Combine multiple days for one animal with pagination
combine_date_plots()
Combine multiple animals for one date with pagination
extract_plots()
Extract subset of plots by animal and/or date

Configuration and Customization

Global Variables

Configure global variables to customize for your data structure.

set_global_cols()
Set multiple global variables at once
tz2()
Get the timezone currently set as global variable
set_tz2()
Set a new timezone which will be used as a global variable governing the processing of timestamp data
id_col2()
Get the name of the column recording animal ID
set_id_col2()
Set the name of the column recording animal ID as global variable
trans_col2()
Get the name of the column recording transponder ID for each visit
set_trans_col2()
Set the name of the column recording transponder ID as global variable
start_col2()
Get the name of the column recording the start time of an event
set_start_col2()
Set the name of the column recording the start time of an event as global variable
end_col2()
Get the name of the column recording the end time of an event
set_end_col2()
Set the name of the column recording the end time of an event as a global variable
bin_col2()
Get the name of the column recording the ID of the bin for each visit
set_bin_col2()
Set the name of the column recording bin ID as global variable
bin_offset2()
Get the numeric bin offset which was set as global variable bin_offset
set_bin_offset2()
Set the numeric bin offset
bins_feed2()
Get the vector of all feed bins included in your study
set_bins_feed2()
Set the vector of all feed bins included in your study as global variable
bins_wat2()
Get the vector of all water bins included in your study
set_bins_wat2()
Set the vector of all water bins included in your study as global variable
duration_col2()
Get the name of the column recording visit duration
set_duration_col2()
Set the name of the duration column as global variable
intake_col2()
Get the name of the column recording feed/water intake
set_intake_col2()
Set the name of the intake column as global variable
start_weight_col2()
Get the name of the column recording start weight
set_start_weight_col2()
Set the name of the start weight column as global variable
end_weight_col2()
Get the name of the column recording end weight
set_end_weight_col2()
Set the name of the end weight column as global variable

Example Data

Example datasets and functions for demonstration.

all_fed
Cattle feeding behavior and visit record data
all_wat
Cattle water drinking behavior and visit record data
clean_feed
Cattle feeding behavior data after quality check and outlier removal
clean_water
Cattle drinking behavior data after quality check and outlier removal
clean_comb
Combined feeding and drinking behavior data with outliers removed
moo4feed_example()
Access Example Data Files Shipped with moo4feed