Calculate Urinary Saturation with the EQUIL2 Algorithm
Overview
Saturation of ionic substances in urine is calculated based on sodium, potassium, calcium, magnesium, ammonia, chloride, phosphate, sulfate, oxalate, citrate, ph, and urate. This program is intended for research use, only. The code within is translated from EQUIL2 Visual Basic code based on Werness, et al (1985) "EQUIL2: a BASIC computer program for the calculation of urinary saturation" doi:10.1016/s0022-5347(17)47703-2 to R. The Visual Basic code was kindly provided by Dr. John Lieske of the Mayo Clinic.
- The
CITATIONfile now usesbibentry() - New function
equil2_v1()ports the original Mayo Clinic class-based VBA module (clsEquil2, attached to issue 2). V1 takes mmol/L inputs, models CO2 / bicarbonate / carbonate chemistry, TRIS buffer, struvite in the Mg / NH4 mass balance, and (when chloride is omitted) auto-fills chloride from electroneutrality. V1 outputs activity products and relative saturation ratios for Calcium Oxalate, Brushite, Struvite, and Uric Acid. For Hydroxyapatite, Sodium Urate, and Ammonium Urate supersaturations (which V1 does not compute) keep usingequil2(). Pyrophosphate input is accepted but disabled inside the algorithm, matching the V1 source. The V1 source code is shipped in the new vignettevignette("original-source-v1"). The R port has been verified against the original VBA module by runningclsEquil2.basin LibreOffice Basic withOption VBASupport 1; on the LabCorp inputs the two agree to better than 10 ppm.
Show all changes in 1.1.0Hide the rest of the changes in 1.1.0
- New units in
add_units():g_carbondioxide,g_pyrophosphate,g_tris(and corresponding mol / mmol variants) for use withequil2_v1()inputs. - Bug fix (#2): corrected the phosphate and sulfate mass-mole conversion factors in
equil2()so that themg_phosphate/dLandmg_sulfate/dLunits now consume actual phosphate (PO4(3-), 94.97 g/mol) and sulfate (SO4(2-), 96.07 g/mol) masses, matching the unit definitions inadd_units(). The original V5 BASIC source uses atomic-weight factors for inorganic P (30.97) and S (32.06), so calling code that supplied unit-aware inputs such asset_units(32, "mmol_phosphate/L")saw approximately 3x over-estimates. The R port has been cross-validated against the V5 BASIC source itself (with the same fix applied) run in LibreOffice Basic; the two agree on ionic strength to ~2 ppb and on the six supersaturation / Gibbs-energy outputs to better than 1 ppm on the LabCorp inputs. Thanks Lea Lerose for the report and diagnosis. Seevignette("original-source")for further discussion and a brief V1-vs-V5 comparison.
From NEWS.md in the release
Install
Health
- OK13 OK2026-08-05
- NOTE12 OK, 1 NOTE2026-08-01
- OK13 OK2026-06-17
- NOTE12 OK, 2 NOTE2026-03-10
Documentation
- Help pages
- 3
- Examples that run
- 100%2 run in a plain check
- Exported functions with examples
- 100%
- Documented parameters
- 13%
- Return-value docs
- 100%
- Help pages citing references
- 67%
Downloads
Repository
- PRs merged (all time)
- 100%
- Median days to close, 50 most recently updated closed issues
- 57
- Median days to close, 50 most recently updated closed PRs
- 0
Forks over time
Releases over time
Issues over time
7 development-tooling and community-health practices detected across 3 families in the upstream repository
Checks run against github.com/billdenney/equil2 on 2026-10-22.
The R CMD check workflow runs on Linux, macOS and Windows, and on R-devel
GitHub Pages site last deployed 2026-06-11 · The repository has a site deploy workflow
pkgdown site last built 2026-06-11
This repository shows signs of AI coding tools.
- Claude Codefirst seen 2026-06-09Named in .Rbuildignore: .claudePull request it wrote: opened by a project memberCommits: at least 5 crediting it in the message
- Claude Opus 4.75 commits · Jun 2026
Dependencies
Code & Tests
People & History
Pick two releases to compare their code metrics.
- 1.1.0Latest
- RR 4.6.0 released · 2026-04-24
- RR 4.5.0 released · 2025-04-11
- RR 4.4.0 released · 2024-04-24
- RR 4.3.0 released · 2023-04-21
- 1.0.02022-12-20
- RR 4.2.0 released · 2022-04-22
Package metadata
- First published
- 2022-12-20
- Total releases
- 2 / 4 yrs
- License
- MIT + file LICENSE OSI
- Download size
- 83 KB
Cite
Cite this package
Run in R for the authors' entry:
citation("equil2")The package provides a citation file, so citation() returns the authors' own entry.
It points to 10.1016/s0022-5347(17)47703-2.
Cite the R Observatory
For a number measured here: a download total, a coverage figure, an archival date.
From data release v2026-10-23, which the citation names so these numbers can be found later. More on citing and the projects behind them.