The hardware and bandwidth for this mirror is donated by METANET, the Webhosting and Full Service-Cloud Provider.
If you wish to report a bug, or if you are interested in having us mirror your free-software or open-source project, please feel free to contact us at mirror[@]metanet.ch.

Tools to estimate the carbon footprint of dairy farms.
Implements methods based on IDF (International Dairy Federation)
and IPCC guidelines for greenhouse gas accounting.
cowfootR provides a comprehensive toolkit for
calculating carbon footprints of dairy farms following IPCC guidelines
(IPCC
2019 Refinement) and International Dairy Federation guidance for the
dairy sector (IDF
Bulletin 520). The package includes:
install.packages("cowfootR")Or install the development version:
devtools::install_github("juanmarcosmoreno-arch/cowfootR")Below is a minimal, end-to-end example showing the core workflow of
cowfootR for a single dairy farm.
library(cowfootR)
# 1. Define system boundaries
boundaries <- set_system_boundaries("farm_gate")
# 2. Calculate emissions by source
enteric <- calc_emissions_enteric(
n_animals = 100,
cattle_category = "dairy_cows",
boundaries = boundaries
)
manure <- calc_emissions_manure(
n_cows = 100,
boundaries = boundaries
)
soil <- calc_emissions_soil(
n_fertilizer_synthetic = 1500,
n_excreta_pasture = 5000,
area_ha = 120,
boundaries = boundaries
)
energy <- calc_emissions_energy(
diesel_l = 2000,
electricity_kwh = 5000,
boundaries = boundaries
)
inputs <- calc_emissions_inputs(
conc_kg = 1000,
fert_n_kg = 500,
boundaries = boundaries
)
# 3. Aggregate total emissions
total_emissions <- calc_total_emissions(enteric, manure, soil, energy, inputs)
total_emissions
#> Carbon Footprint - Total Emissions
#> ==================================
#> Total CO2eq: 451512.6 kg
#> Number of sources: 5
#>
#> Breakdown by source:
#> energy : 5740 kg CO2eq
#> enteric : 312800 kg CO2eq
#> inputs : 4000 kg CO2eq
#> manure : 89880 kg CO2eq
#> soil : 39092.62 kg CO2eq
#>
#> Calculated on: 2026-01-08
# 4. Intensity metrics
milk_intensity <- calc_intensity_litre(
total_emissions = total_emissions,
milk_litres = 750000,
fat = 4.0,
protein = 3.3
)
milk_intensity
#> Carbon Footprint Intensity
#> ==========================
#> Intensity: 0.585 kg CO2eq/kg FPCM
#>
#> Production data:
#> Raw milk (L): 750,000 L
#> Raw milk (kg): 772,500 kg
#> FPCM (kg): 772,407 kg
#> Fat content: 4 %
#> Protein content: 3.3 %
#>
#> Total emissions: 451,513 kg CO2eq
#> Calculated on: 2026-01-08
area_intensity <- calc_intensity_area(
total_emissions = total_emissions,
area_total_ha = 120
)
area_intensity
#> Carbon Footprint Area Intensity
#> ===============================
#> Intensity (total area): 3762.61 kg CO2eq/ha
#> Intensity (productive area): 3762.61 kg CO2eq/ha
#>
#> Area summary:
#> Total area: 120 ha
#> Productive area: 120 ha
#> Land use efficiency: 100%
#>
#> Total emissions: 451,513 kg CO2eq
#> Calculated on: 2026-01-08In practical applications, cowfootR is most often used
to process data from multiple farms simultaneously. This is handled
through the calc_batch() function, which applies the same
methodological workflow across all farms in a structured dataset.
Below is a minimal example illustrating batch processing for multiple farms.
library(cowfootR)
# Example dataset with two farms
farms <- data.frame(
FarmID = c("Farm_A", "Farm_B"),
Year = c(2023, 2023),
Milk_litres = c(500000, 750000),
Cows_milking = c(90, 130),
Area_total_ha = c(110, 160),
Diesel_litres = c(4000, 6500),
Electricity_kWh = c(18000, 26000),
Concentrate_feed_kg = c(120000, 180000),
stringsAsFactors = FALSE
)
# Define system boundaries
boundaries <- set_system_boundaries("farm_gate")
# Run batch carbon footprint calculation
batch_results <- calc_batch(
data = farms,
tier = 2,
boundaries = boundaries,
benchmark_region = "uruguay"
)
#> Batch: 2 rows; tier=2 ...
# Summary of batch processing
batch_results$summary
#> $n_farms_processed
#> [1] 2
#>
#> $n_farms_successful
#> [1] 2
#>
#> $n_farms_with_errors
#> [1] 0
#>
#> $boundaries_used
#> $boundaries_used$scope
#> [1] "farm_gate"
#>
#> $boundaries_used$include
#> [1] "enteric" "manure" "soil" "energy" "inputs"
#>
#>
#> $benchmark_region
#> [1] "uruguay"
#>
#> $processing_date
#> [1] "2026-01-08"
# Farm-level results
batch_results$farm_results
#> [[1]]
#> [[1]]$success
#> [1] TRUE
#>
#> [[1]]$farm_id
#> [1] "Farm_A"
#>
#> [[1]]$year
#> [1] "2023"
#>
#> [[1]]$emissions_enteric
#> [1] 230826.6
#>
#> [[1]]$emissions_manure
#> [1] 183066.1
#>
#> [[1]]$emissions_soil
#> [1] 0
#>
#> [[1]]$emissions_energy
#> [1] 13794
#>
#> [[1]]$emissions_inputs
#> [1] 84000
#>
#> [[1]]$emissions_total
#> [1] 511686.8
#>
#> [[1]]$intensity_milk_kg_co2eq_per_kg_fpcm
#> [1] 0.9936858
#>
#> [[1]]$intensity_area_kg_co2eq_per_ha_total
#> [1] 4651.7
#>
#> [[1]]$intensity_area_kg_co2eq_per_ha_productive
#> [1] 4651.7
#>
#> [[1]]$fpcm_production_kg
#> [1] 514938.2
#>
#> [[1]]$milk_production_kg
#> [1] 515000
#>
#> [[1]]$milk_production_litres
#> [1] 5e+05
#>
#> [[1]]$land_use_efficiency
#> [1] 1
#>
#> [[1]]$total_animals
#> [1] 90
#>
#> [[1]]$dairy_cows
#> [1] 90
#>
#> [[1]]$benchmark_region
#> [1] "uruguay"
#>
#> [[1]]$benchmark_performance
#> [1] "Excellent (below typical range)"
#>
#> [[1]]$processing_date
#> [1] "2026-01-08"
#>
#> [[1]]$boundaries_used
#> [1] "farm_gate"
#>
#> [[1]]$tier_used
#> [1] "tier_2"
#>
#> [[1]]$detailed_objects
#> NULL
#>
#>
#> [[2]]
#> [[2]]$success
#> [1] TRUE
#>
#> [[2]]$farm_id
#> [1] "Farm_B"
#>
#> [[2]]$year
#> [1] "2023"
#>
#> [[2]]$emissions_enteric
#> [1] 333416.3
#>
#> [[2]]$emissions_manure
#> [1] 264428.9
#>
#> [[2]]$emissions_soil
#> [1] 0
#>
#> [[2]]$emissions_energy
#> [1] 22142.25
#>
#> [[2]]$emissions_inputs
#> [1] 126000
#>
#> [[2]]$emissions_total
#> [1] 745987.4
#>
#> [[2]]$intensity_milk_kg_co2eq_per_kg_fpcm
#> [1] 0.9657954
#>
#> [[2]]$intensity_area_kg_co2eq_per_ha_total
#> [1] 4662.42
#>
#> [[2]]$intensity_area_kg_co2eq_per_ha_productive
#> [1] 4662.42
#>
#> [[2]]$fpcm_production_kg
#> [1] 772407.3
#>
#> [[2]]$milk_production_kg
#> [1] 772500
#>
#> [[2]]$milk_production_litres
#> [1] 750000
#>
#> [[2]]$land_use_efficiency
#> [1] 1
#>
#> [[2]]$total_animals
#> [1] 130
#>
#> [[2]]$dairy_cows
#> [1] 130
#>
#> [[2]]$benchmark_region
#> [1] "uruguay"
#>
#> [[2]]$benchmark_performance
#> [1] "Excellent (below typical range)"
#>
#> [[2]]$processing_date
#> [1] "2026-01-08"
#>
#> [[2]]$boundaries_used
#> [1] "farm_gate"
#>
#> [[2]]$tier_used
#> [1] "tier_2"
#>
#> [[2]]$detailed_objects
#> NULL
# Export results to Excel
export_hdc_report(
batch_results,
file = "cowfootR_batch_report.xlsx"
)
#> Batch report saved to: cowfootR_batch_report.xlsxBatch results can be directly exported to an Excel report using
export_hdc_report(), facilitating integration with
reporting workflows commonly used by consultants, researchers, and
stakeholders.
boundaries_fg <- set_system_boundaries("farm_gate")
boundaries_cfg <- set_system_boundaries("cradle_to_farm_gate")The package calculates multiple intensity metrics:
FarmID: Unique farm identifierYear: Year of data collectionMilk_litres: Annual milk production (liters)Cows_milking: Number of milking cowsArea_total_ha: Total farm area (hectares)Cows_dry, Heifers_total,
Calves_total, Bulls_totalFat_percent, Protein_percent,
Milk_yield_kg_cow_yearMS_intake_cows_milking_kg_day,
Ym_percent, Concentrate_feed_kgN_fertilizer_kg,
N_fertilizer_organic_kgDiesel_litres, Electricity_kWh,
Petrol_litresArea_productive_ha,
Pasture_permanent_haUse cf_download_template() to get the complete column
structure.
The package includes robust error handling for batch processing:
For batch processing, Excel templates, reporting, and error handling, please see the package vignettes and the documentation website.
This package is under active development. Please report issues or suggest improvements on GitHub.
MIT License © 2025 Juan Moreno
These binaries (installable software) and packages are in development.
They may not be fully stable and should be used with caution. We make no claims about them.