Estimated glomerular filtration rate (eGFR) calculation

knitr::opts_chunk$set(
  collapse = TRUE,
  comment = "#>"
)

Estimated glomerular filtration rate (eGFR) calculation

kidney.epi R package includes functions for calculation of eGFR by different equations.

Data frames

library(kidney.epi)
head(ckd.data)

Functions to calculate eGFR by different equations

kidney.epi contains a set of functions to calculate eGFR by different equations either for a single patient or for a dataset.

The following eGFR equations are supported:

If you use these functions from kidney.epi package for the data analysis and manuscript preparation, please cite the package: "Bikbov B. kidney.epi: Kidney-Related Functions for Clinical and Epidemiological Research. Scientific-Tools.Org, https://Scientific-Tools.Org. doi:10.32614/CRAN.package.kidney.epi".

Contact us for data analysis or software development at Scientific-Tools.Org or via 'maintainer("kidney.epi")', connect with the author on LinkedIn.

Examples

The vignette demonstrates the usage of eGFR calculation by the CKD-EPI 2009 equation, but race-free CKD-EPI 2021 and other equations work in the same way.

Example for a single patient

To calculate for a single patient, use the following syntax:

# call egfr.ckdepi.cr.2009 function, and directly set parameters values
egfr.ckdepi.cr.2009(
  creatinine = 1.4,  
  age = 60,  
  sex = "Male", 
  ethnicity = "White", 
  creatinine_units = "mg/dl", 
  label_afroamerican = c("Afroamerican"), 
  label_sex_male = c("Male"), 
  label_sex_female = c("Female")
)

# Definitions of the labels for sex and race are optional if you use the same labels defined as default in the function. The following also works well:
egfr.ckdepi.cr.2009(
  creatinine = 1.4,  
  age = 60,  
  sex = "Male", 
  ethnicity = "White", 
  creatinine_units = "mg/dl"
)

# If you measure creatinine in micromol/l, it is possible to omit also 'creatinine_units' since the default value is "micromol/l":
egfr.ckdepi.cr.2009(
  creatinine = 103, # creatinine is in micromol/l
  age = 60,  
  sex = "Male", 
  ethnicity = "White"
)

Example for a cohort of patients

To calculate eGFR for a cohort of patients in a dataset, use the following syntax:

# copy as an example the internal dataframe ckd.data from R package to your dataframe
mydata <- ckd.data

# calculate eGFR by CKD-EPI equation
mydata$ckdepi <- egfr.ckdepi.cr.2009(
  creatinine = mydata$cr, age = mydata$age,
  sex = mydata$sex, ethnicity = mydata$ethnicity,
  creatinine_units = "micromol/L",
  # customize all labels for those used in the data frame
  # label(s) used to define male sex in the dataset
  label_sex_male = c("Male"), 
  # label(s) used to define female sex in the dataset
  label_sex_female = c("Female"),
  # label used to define Afroamerican ethnicity in the dataset
  label_afroamerican = c("Black")
) 

# show descriptive stat for the calculated values
# note that synthetic data set ckd.data contains input parameters for both adults and children, and since the CKD-EPI equation was developed and validated for adults only, the resulting eGFR values for children will be NA. Use children-specific eGFR equations when necessary.
summary(mydata$ckdepi)

Advantages of the kidney.epi package functions

There are several advantages of the kidney.epi package functions for calculating eGFR values:

References

References for each eGFR equation are listed in the documentation to the package.



Try the kidney.epi package in your browser

Any scripts or data that you put into this service are public.

kidney.epi documentation built on June 8, 2025, 10:54 a.m.