kidney.epi R package includes functions for calculation of eGFR by different equations.
See also: [kidneyepidemiology.org web site] id
library(kidney.epi)
head(ktx)
#>   ptid rec.age don.age don.height don.weight don.ethnicity
#> 1  149    62.5      68        155       60.0         White
#> 2  385    53.5      43        180       90.0         White
#> 3  299    69.6      78        168       70.0         White
#> 4  224    74.3      68        180      113.0         White
#> 5  330    71.5      73        171       68.0         White
#> 6  428    67.1      72        163       68.6         White
#>   don.hypertension don.diabetes don.causeofdeath don.creatinine don.hcv
#> 1              Yes           No  cerebrovascular           0.68       N
#> 2              N/A          N/A           trauma           0.76       N
#> 3              Yes           No  cerebrovascular           0.82       N
#> 4              Yes           No  cerebrovascular           1.97       N
#> 5              Yes           No           trauma           0.63       N
#> 6               No           No  cerebrovascular           1.13       N
#>   don.dcdstatus don.sex
#> 1            No    Male
#> 2           Yes  Female
#> 3            No    Male
#> 4            No  Female
#> 5            No    Male
#> 6           Yes  FemaleThere is a set of functions which calculate eGFR by different equations either for a single patient or for a dataset.
Currently, the following eGFR equations are supported: - CKD-EPI: function egfr.ckdepi - MDRD: function egfr.mdrd4 - Schwartz: function egfr.schwartz
If you use these functions and kidney.epi package for preparation of a manuscript, please use the following citation: “Bikbov B. R open source programming code for calculation of the Kidney Donor Profile Index and Kidney Donor Risk Index. Kidney Disease. 2018; 4:269–272 :10.1159/000492427”.
To calculate for a single patient, use the following syntax:
# call egfr.ckdepi function, and directly set parameters values
egfr.ckdepi (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"))
#> [1] 54.22To calculate for a multiple patients in a dataset, use the following syntax:
# copy as an example the internal dataframe ktx from R package to your dataframe
mydata <- ktx
# calculate eGFR by CKD-EPI equation
mydata$ckdepi <- egfr.ckdepi ( creatinine = mydata$don.creatinine, age = mydata$don.age,
  sex = mydata$don.sex, ethnicity = mydata$don.ethnicity, creatinine_units = "mg/dl",
  # customize all labels used in the dataframe
  label_afroamerican = c ("Afroamerican"),
  label_sex_male = c ("Male"), label_sex_female = c ("Female")) 
# show descriptive stat for the calculated values
summary(mydata$ckdepi)
#>    Min. 1st Qu.  Median    Mean 3rd Qu.    Max. 
#>   25.56   55.92   82.86   72.99   94.60   98.13Take into account that the labels defined in the function parameters have to correspond to the labels used in your data frame. In the example above label for male sex is defined as label_sex_male = c (“Male”) that means in the data frame it should be “Male”. In case you use different labelling in your data frame, define this appropriatelly. For example, if you define female sex as “F” and male sex as “M” in your data frame, you have to change the labeling in paremeters of the function to label_sex_male = c (“M”), label_sex_female = c (“F”).
References for each eGFR equation are listed in the documentation to the package.