
One package. Five dimensions. Ten interlinkages. A comprehensive R package for Water-Energy-Food-Nutrient-Carbon (WEFNC) nexus analysis in agricultural production systems.
Modern agriculture doesn’t work in silos. When we save water, it affects energy use. When we add fertilizers, it impacts carbon emissions. When we change tillage, it affects food production, soil health, and everything in between.
wefnexus connects all 5 dimensions in one package — giving researchers, policymakers, and agronomists the tools to see the full picture and make decisions that are truly sustainable.
Install the stable version from CRAN:
install.packages("wefnexus")Or install the development version from GitHub:
# install.packages("devtools")
devtools::install_github("lalitrolaniya/wefnexus")nexus_analysis() takes plot-level data (treatment x
replication) and returns indicators, an ANOVA table, the composite nexus
index and a TOPSIS ranking.nexus_anova()
gives means with letter groups, SEm, CD (5%) and CV for CRD and RCBD
trials.nexus_weights()
derives weights by entropy, CRITIC or PCA instead of assuming equal
weights.nexus_topsis() ranks
treatments on raw indicators.energy_budget() turns litres, kilograms and labour hours
into MJ/ha, with direct/indirect and renewable/non-renewable shares,
using an editable energy_coefficients table.nexus_rank_compare()
ranks treatments eight ways and reports Kendall’s W, so you can show a
recommendation does not hinge on one choice of weights.plot()
works on every result: means with error bars and letters, radar small
multiples, TOPSIS rankings, energy budgets, and a trade-off heatmap with
significance stars, all in a colour-blind-checked palette.nexus_summary(nutrient_metric = "iue") works when no
fertilizer N is applied; ef_n2o = 0.005 applies the IPCC
dry-climate N2O factor.soil_carbon_stock()
was 10 times too low, and nexus_heatmap_gg() swapped row
labels; also fixed NHI in nutrient_use_efficiency(),
water_footprint(area) and nexus_summary(). See
NEWS.| Module | Functions | Key metrics |
|---|---|---|
| 💧 Water | 7 | WUE, WP (physical/economic), WF (green/blue/grey), irrigation efficiency, CWSI, CWP, depleted fraction |
| ⚡ Energy | 11 | Energy budget from quantities, EUE, EROI, EP, energy intensity, specific energy, net energy, energy profitability |
| 🌾 Food | 8 | FPI, crop yield index, HI, LER, SPI, caloric and protein yield, PEI |
| 🧪 Nutrient | 8 | AE, PE, RE, PFP, IUE, NHI, NPK balance, one-call NUE report |
| 🌿 Carbon | 7 | CF (source-wise), GHG (IPCC Tier 1), SOC stock, sequestration rate, GWP (AR6), CSI |
| 🔗 Nexus | 16 | Normalization, composite index, entropy/CRITIC/PCA weights, TOPSIS, ranking robustness (Kendall’s W), trade-off matrix and heatmap, sensitivity, radar, heatmap |
| 🧭 Workflow | 2 | nexus_analysis(), nexus_anova() |
library(wefnexus)
options(wefnexus.verbose = FALSE) # silence messages
data(arid_pulse_trial) # 6 treatments x 3 replications (RCBD)
res <- nexus_analysis(
arid_pulse_trial,
treatment = "treatment", block = "replication",
yield = "grain_yield", water = "total_water",
energy_in = "energy_input", energy_out = "energy_output",
emission = "ghg_emission", n_uptake = "n_uptake",
weights = "entropy"
)
res # nexus index and TOPSIS ranks
res$anova # means + letters, SEm, CD (5%), CV
plot(res$nexus)plot(res$anova, response = c("grain_yield", "WUE", "EUE", "CI"), ncol = 2)
plot(res) # one radar per treatment, dashed line = mean of all treatments
nx <- res$nexus
indicators <- data.frame(WUE = nx$WUE_kg_mm, EUE = nx$EUE_ratio,
Yield = nx$yield_kg_ha, IUE = nx$IUE_kg_kgN,
CI = nx$carbon_intensity)
rc <- nexus_rank_compare(indicators, benefit = c(TRUE, TRUE, TRUE, TRUE, FALSE),
treatment_names = nx$treatment)
plot(rc) # do rankings hold across eight weighting/aggregation methods?
inputs <- data.frame(
treatment = c("CT", "ZT"),
human_labour_man = c(320, 240), diesel = c(65, 38),
electricity = c(180, 75), nitrogen = c(20, 20), phosphorus = c(40, 40),
seed = c(20, 20), herbicide = c(0, 0.75),
grain = c(980, 1280), straw = c(1450, 1850)
)
energy_budget(inputs)data(arid_pulse_nexus)
d <- arid_pulse_nexus
water_use_efficiency(d$grain_yield, d$total_water)
eroi(d$energy_output_grain + d$energy_output_straw, d$energy_input)
carbon_footprint(diesel_use = 65, electricity_use = 180,
n_fertilizer = 20, yield = 980, ef_n2o = 0.005)print(),
summary() and plot() methods# Complete vignette with all 6 modules
browseVignettes("wefnexus")
# View the built-in sample dataset
?arid_pulse_nexus
# Help for any function
?carbon_footprint
?nexus_summary
?water_use_efficiency📖 Full documentation website: https://lalitrolaniya.github.io/wefnexus/
Use replication-level data (one row per plot) where
you can. It keeps the variability needed for ANOVA, SEm and CD, and
nexus_analysis() handles the aggregation to treatment
means. Treatment means also work; ANOVA is then skipped.
If you use wefnexus in your research, please cite:
citation("wefnexus")Rolaniya, L.K., Poonia, H., Jat, R.L., Punia, M. & Choudhary, R.R. (2026).
wefnexus: Water-Energy-Food-Nutrient-Carbon Nexus Analysis for Agronomic
Systems. R package version 1.1.0. https://CRAN.R-project.org/package=wefnexus
DOI: 10.32614/CRAN.package.wefnexus
| Author | Affiliation |
|---|---|
| Lalit Kumar Rolaniya (maintainer) | Scientist (Agronomy), ICAR-IIPR RC Bikaner |
| Hemant Poonia (deceased) | Assistant Professor, Dept of Mathematics & Statistics, CCS HAU Hisar |
| Ram Lal Jat | Scientist, ICAR-IIPR RC Bikaner |
| Monika Punia (deceased) | Scientist, ICAR-IIPR RC Bikaner |
| Raja Ram Choudhary | Scientist, ICAR-IIGR RRS Bikaner |
Version 1.1.0 is dedicated to the memory of our co-authors Dr. Monika Punia and Dr. Hemant Poonia.
| Resource | URL |
|---|---|
| 📦 CRAN | https://CRAN.R-project.org/package=wefnexus |
| 📖 Documentation | https://lalitrolaniya.github.io/wefnexus/ |
| 💻 Source Code | https://github.com/lalitrolaniya/wefnexus |
| 🔗 DOI | 10.32614/CRAN.package.wefnexus |
We welcome contributions! Please see CONTRIBUTING.md for guidelines.
Found a bug? Have a feature request? Open an issue
If you find this package useful, please ⭐ star this repository — it helps others discover it!
GPL (>= 3)