diff --git a/DESCRIPTION b/DESCRIPTION
index cdd0d21..18c3e78 100644
--- a/DESCRIPTION
+++ b/DESCRIPTION
@@ -1,7 +1,7 @@
Package: epocakir
Title: Clinical Coding of Patients with Kidney Disease using Clinical Practice
Guidelines
-Version: 0.9.0
+Version: 0.9.5
Authors@R:
c(person(given = "Alwin",
family = "Wang",
diff --git a/LICENSE b/LICENSE
index 931e5ce..d01e40b 100644
--- a/LICENSE
+++ b/LICENSE
@@ -1,6 +1,6 @@
# MIT License
-Copyright (c) 2020 Alwin Wang, Lisa Toh
+Copyright (c) 2021 Alwin Wang, Lisa Toh
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
diff --git a/NAMESPACE b/NAMESPACE
index 91d5274..43b3405 100644
--- a/NAMESPACE
+++ b/NAMESPACE
@@ -1,50 +1,50 @@
# Generated by roxygen2: do not edit by hand
-S3method(Albuminuria_staging_ACR,default)
+S3method(Albuminuria_staging_ACR,data.frame)
S3method(Albuminuria_staging_ACR,numeric)
S3method(Albuminuria_staging_ACR,units)
-S3method(Albuminuria_staging_AER,default)
+S3method(Albuminuria_staging_AER,data.frame)
S3method(Albuminuria_staging_AER,numeric)
S3method(Albuminuria_staging_AER,units)
-S3method(GFR_staging,default)
+S3method(GFR_staging,data.frame)
S3method(GFR_staging,numeric)
S3method(GFR_staging,units)
-S3method(aki,default)
-S3method(aki,numeric)
-S3method(aki,units)
-S3method(aki_SCr,default)
+S3method(aki_SCr,data.frame)
S3method(aki_SCr,numeric)
S3method(aki_SCr,units)
-S3method(aki_UO,default)
+S3method(aki_UO,data.frame)
S3method(aki_UO,numeric)
S3method(aki_UO,units)
-S3method(aki_bCr,default)
+S3method(aki_bCr,data.frame)
S3method(aki_bCr,numeric)
S3method(aki_bCr,units)
-S3method(anemia,default)
+S3method(aki_staging,data.frame)
+S3method(aki_staging,numeric)
+S3method(aki_staging,units)
+S3method(anemia,data.frame)
S3method(anemia,numeric)
S3method(anemia,units)
S3method(combn_changes,POSIXct)
-S3method(combn_changes,default)
-S3method(eGFR,default)
+S3method(combn_changes,data.frame)
+S3method(eGFR,data.frame)
S3method(eGFR,numeric)
S3method(eGFR,units)
-S3method(eGFR_adult_SCr,default)
+S3method(eGFR_adult_SCr,data.frame)
S3method(eGFR_adult_SCr,numeric)
S3method(eGFR_adult_SCr,units)
-S3method(eGFR_adult_SCr_SCysC,default)
+S3method(eGFR_adult_SCr_SCysC,data.frame)
S3method(eGFR_adult_SCr_SCysC,numeric)
S3method(eGFR_adult_SCr_SCysC,units)
-S3method(eGFR_adult_SCysC,default)
+S3method(eGFR_adult_SCysC,data.frame)
S3method(eGFR_adult_SCysC,numeric)
S3method(eGFR_adult_SCysC,units)
-S3method(eGFR_child_SCr,default)
+S3method(eGFR_child_SCr,data.frame)
S3method(eGFR_child_SCr,numeric)
S3method(eGFR_child_SCr,units)
-S3method(eGFR_child_SCr_BUN,default)
+S3method(eGFR_child_SCr_BUN,data.frame)
S3method(eGFR_child_SCr_BUN,numeric)
S3method(eGFR_child_SCr_BUN,units)
-S3method(eGFR_child_SCysC,default)
+S3method(eGFR_child_SCysC,data.frame)
S3method(eGFR_child_SCysC,numeric)
S3method(eGFR_child_SCysC,units)
export("%>%")
@@ -53,10 +53,11 @@ export(Albuminuria_staging_ACR)
export(Albuminuria_staging_AER)
export(GFR_stages)
export(GFR_staging)
-export(aki)
export(aki_SCr)
export(aki_UO)
export(aki_bCr)
+export(aki_stages)
+export(aki_staging)
export(anemia)
export(as_metric)
export(binary2factor)
@@ -72,4 +73,3 @@ export(eGFR_child_SCr_BUN)
export(eGFR_child_SCysC)
importFrom(magrittr,"%>%")
importFrom(rlang,.data)
-importFrom(rlang,`:=`)
diff --git a/R/Txp-recipient.R b/R/Txp-recipient.R
index 6ac09ac..e74fb23 100644
--- a/R/Txp-recipient.R
+++ b/R/Txp-recipient.R
@@ -1,2 +1 @@
-# ?additional conversion factors
# NULL
diff --git a/R/aki.R b/R/aki.R
index 9deaa3e..bf60d1a 100644
--- a/R/aki.R
+++ b/R/aki.R
@@ -1,53 +1,75 @@
-
+#' AKI Stages
+#'
+#' Ordered factor of AKI stages
+#'
+#' See for more details
+#'
+#' @export
+#' @examples
+#' aki_stages
aki_stages <- factor(
c("AKI Stage 1", "AKI Stage 2", "AKI Stage 3", "No AKI"),
levels = c("No AKI", "AKI Stage 1", "AKI Stage 2", "AKI Stage 3"),
ordered = TRUE
)
-aki_staging <- function() {}
-
#' Codify AKI from Serum Creatinine and/or Urine Output
#'
-#' Using KDIGO Clinical Practice Guideline for Acute Kidney Injury
+#' Using KDIGO Clinical Practice Guideline for
+#' Acute Kidney Injury
#' Volume 2 | Issue 1 | March 2012
#'
-#' Provided a series of Serum Creatinine readings and/or Urine Output, aki()
-#' calculates whether or not a patient has AKI. The staging (1, 2, 3) of AKI is
-#' also calculated
+#' Provided a baseline creatinine, series of Serum Creatinine readings and/or
+#' Urine Output, `aki_staging()` calculates whether or not a patient has AKI.
+#' The staging (1, 2, 3) of AKI is returned.
+#'
+#' When multiple columns are provided, `aki_staging()` will automatically
+#' calculate whether or not AKI has occurred using each KDIGIO definition.
+#'
+#' \itemize{
+#' \item{[`aki_bCr()`]: Staging of AKI based on baseline serum creatinine}
+#' \item{[`aki_SCr()`]: Staging of AKI based on changes in serum creatinine}
+#' \item{[`aki_UO()`]: Staging of AKI based on urine output}
+#' }
+#'
+#' The most severe AKI stage is then returned.
+#'
+#' See for more details.
#'
#' @param .data (data.frame) A data.frame, optional
#' @param SCr Serum creatinine
-#' column name, or vector if `.data` not provided
+#' column name, or vector of units or numeric if `.data` is not provided
#' @param bCr Baseline creatinine
-#' column name, or vector if `.data` not provided
+#' column name, or vector of units or numeric if `.data` is not provided
#' @param UO Urine output
-#' column name, or vector if `.data` not provided
+#' column name, or vector of units or numeric if `.data` is not provided
#' @param dttm DateTime
-#' column name, or vector if `.data` not provided
+#' column name, or vector of POSIXct if `.data` is not provided
#' @param pt_id Patient ID
-#' column name, or vector if `.data` not provided
+#' column name, or vector of characters or factors if `.data` is not provided
#' @param ... Further optional arguments
#'
#' @examples
-#' print("todo")
+#' aki_staging(aki_pt_data, SCr = "SCr_", bCr = "bCr_", UO = "UO_", dttm = "dttm_", pt_id = "pt_id_")
+#'
+#' aki_pt_data %>%
+#' dplyr::mutate(aki = aki_staging(SCr = SCr_, bCr = bCr_, UO = UO_, dttm = dttm_, pt_id = pt_id_))
#' @importFrom rlang .data
-#' @importFrom rlang `:=`
#' @export
-aki <- function(...) {
+aki_staging <- function(...) {
ellipsis::check_dots_used()
- UseMethod("aki")
+ UseMethod("aki_staging")
}
-#' @rdname aki
+#' @rdname aki_staging
#' @export
-aki.default <- function(.data,
- SCr = NULL,
- bCr = NULL,
- UO = NULL,
- dttm = NULL,
- pt_id = NULL,
- ...) {
+aki_staging.data.frame <- function(.data,
+ SCr = NULL,
+ bCr = NULL,
+ UO = NULL,
+ dttm = NULL,
+ pt_id = NULL,
+ ...) {
ellipsis::check_dots_used()
if (!is.null(SCr)) SCr <- .data[[rlang::as_name(rlang::enquo(SCr))]]
if (!is.null(bCr)) bCr <- .data[[rlang::as_name(rlang::enquo(bCr))]]
@@ -56,42 +78,42 @@ aki.default <- function(.data,
if (!is.null(pt_id)) pt_id <- .data[[rlang::as_name(rlang::enquo(pt_id))]]
if (!is.null(SCr)) {
- aki(SCr = SCr, bCr = bCr, UO = UO, dttm = dttm, pt_id = pt_id)
+ aki_staging(SCr = SCr, bCr = bCr, UO = UO, dttm = dttm, pt_id = pt_id)
} else {
- aki(UO = UO, dttm = dttm, pt_id = pt_id)
+ aki_staging(UO = UO, dttm = dttm, pt_id = pt_id)
}
}
-#' @rdname aki
+#' @rdname aki_staging
#' @export
-aki.units <- function(
- SCr = NULL,
- bCr = NULL,
- UO = NULL,
- dttm = NULL,
- pt_id = NULL,
- ...) {
+aki_staging.units <- function(
+ SCr = NULL,
+ bCr = NULL,
+ UO = NULL,
+ dttm = NULL,
+ pt_id = NULL,
+ ...) {
ellipsis::check_dots_used()
if (!is.null(SCr)) SCr <- as_metric(SCr = SCr, value_only = T)
if (!is.null(bCr)) bCr <- as_metric(SCr = bCr, value_only = T)
if (!is.null(UO)) UO <- as_metric(UO = UO, value_only = T)
if (!is.null(SCr)) {
- aki(SCr = SCr, bCr = bCr, UO = UO, dttm = dttm, pt_id = pt_id)
+ aki_staging(SCr = SCr, bCr = bCr, UO = UO, dttm = dttm, pt_id = pt_id)
} else {
- aki(UO = UO, dttm = dttm, pt_id = pt_id)
+ aki_staging(UO = UO, dttm = dttm, pt_id = pt_id)
}
}
-#' @rdname aki
+#' @rdname aki_staging
#' @export
-aki.numeric <- function(
- SCr = NULL,
- bCr = NULL,
- UO = NULL,
- dttm = NULL,
- pt_id = NULL,
- ...) {
+aki_staging.numeric <- function(
+ SCr = NULL,
+ bCr = NULL,
+ UO = NULL,
+ dttm = NULL,
+ pt_id = NULL,
+ ...) {
ellipsis::check_dots_used()
if (!is.null(dttm) & is.null(pt_id)) {
@@ -118,27 +140,42 @@ aki.numeric <- function(
}
-#' AKI Staging based on baseline creatinine
+#' AKI Staging based on Baseline Serum Creatinine
+#'
+#' Using KDIGO Clinical Practice Guideline for
+#' Acute Kidney Injury
+#' Volume 2 | Issue 1 | March 2012
+#'
+#' \itemize{
+#' \item{AKI Stage 1: 1.5-1.9 times baseline}
+#' \item{AKI Stage 2: 2.0-2.9 times baseline}
+#' \item{AKI Stage 3: 3.0 times baseline}
+#' }
+#'
+#' See for more details.
#'
#' @param .data (data.frame) A data.frame, optional
#' @param SCr Serum creatinine
-#' column name, or vector if `.data` not provided
+#' column name, or vector of units or numeric if `.data` is not provided
#' @param bCr Baseline creatinine
-#' column name, or vector if `.data` not provided
+#' column name, or vector of units or numeric if `.data` is not provided
#' @param ... Further optional arguments
#'
#' @return (ordered factor) AKI stages
#' @export
#'
#' @examples
-#' print("todo")
+#' aki_bCr(aki_pt_data, SCr = "SCr_", bCr = "bCr_")
+#'
+#' aki_pt_data %>%
+#' dplyr::mutate(aki = aki_bCr(SCr = SCr_, bCr = bCr_))
aki_bCr <- function(...) {
UseMethod("aki_bCr")
}
#' @rdname aki_bCr
#' @export
-aki_bCr.default <- function(.data, SCr, bCr, ...) {
+aki_bCr.data.frame <- function(.data, SCr, bCr, ...) {
ellipsis::check_dots_used()
aki_bCr(
.data[[rlang::as_name(rlang::enquo(SCr))]],
@@ -170,29 +207,44 @@ aki_bCr.numeric <- function(SCr, bCr, ...) {
}
-#' AKI Staging based on changes in creatinine
+#' AKI Staging based on Changes in Serum Creatinine
+#'
+#' Using KDIGO Clinical Practice Guideline for
+#' Acute Kidney Injury
+#' Volume 2 | Issue 1 | March 2012
+#'
+#' \itemize{
+#' \item{AKI Stage 1: \eqn{\ge}0.3 mg/dl (\eqn{\ge}26.5 mmol/l) increase}
+#' \item{AKI Stage 2: N/A}
+#' \item{AKI Stage 3: \eqn{\ge}4.0 mg/dl (\eqn{\ge}353.6 mmol/l)}
+#' }
+#'
+#' See for more details.
#'
#' @param .data (data.frame) A data.frame, optional
#' @param dttm DateTime
-#' column name, or vector if `.data` not provided
+#' column name, or vector of POSIXct if `.data` is not provided
#' @param SCr Serum creatinine
-#' column name, or vector if `.data` not provided
+#' column name, or vector of units or numeric if `.data` is not provided
#' @param pt_id Patient ID
-#' column name, or vector if `.data` not provided
+#' column name, or vector of characters or factors if `.data` is not provided
#' @param ... Further optional arguments
#'
#' @return (ordered factor) AKI stages
#' @export
#'
#' @examples
-#' print("todo")
+#' aki_SCr(aki_pt_data, SCr = "SCr_", dttm = "dttm_", pt_id = "pt_id_")
+#'
+#' aki_pt_data %>%
+#' dplyr::mutate(aki = aki_SCr(SCr = SCr_, dttm = dttm_, pt_id = pt_id_))
aki_SCr <- function(...) {
UseMethod("aki_SCr")
}
#' @rdname aki_SCr
#' @export
-aki_SCr.default <- function(.data, SCr, dttm, pt_id, ...) {
+aki_SCr.data.frame <- function(.data, SCr, dttm, pt_id, ...) {
ellipsis::check_dots_used()
aki_SCr(
.data[[rlang::as_name(rlang::enquo(SCr))]],
@@ -220,6 +272,7 @@ aki_SCr.numeric <- function(SCr, dttm, pt_id, ...) {
dplyr::mutate(
.aki = dplyr::case_when(
D.val >= 0.3 & D.dttm < lubridate::duration(hours = 48) ~ aki_stages[1],
+ D.val >= 4.0 ~ aki_stages[3],
TRUE ~ dplyr::last(aki_stages)
)
) %>%
@@ -237,29 +290,45 @@ aki_SCr.numeric <- function(SCr, dttm, pt_id, ...) {
dplyr::pull(.data$.aki)
}
-#' AKI Staging based on urine output
+
+#' AKI Staging based on Urine Output
+#'
+#' Using KDIGO Clinical Practice Guideline for
+#' Acute Kidney Injury
+#' Volume 2 | Issue 1 | March 2012
+#'
+#' \itemize{
+#' \item{AKI Stage 1: <0.5 ml/kg/h for 6–12 hours}
+#' \item{AKI Stage 2: <0.5 ml/kg/h for \eqn{\ge}12 hours}
+#' \item{AKI Stage 3: <0.3 ml/kg/h for \eqn{\ge}24 hours OR Anuria for \eqn{\ge}12 hours}
+#' }
+#'
+#' See for more details.
#'
#' @param .data (data.frame) A data.frame, optional
#' @param dttm DateTime
-#' column name, or vector if `.data` not provided
+#' column name, or vector of POSIXct if `.data` is not provided
#' @param UO Urine output
-#' column name, or vector if `.data` not provided
+#' column name, or vector of units or numeric if `.data` is not provided
#' @param pt_id Patient ID
-#' column name, or vector if `.data` not provided
+#' column name, or vector of characters or factors if `.data` is not provided
#' @param ... Further optional arguments
#'
#' @return (ordered factor) AKI stages
#' @export
#'
#' @examples
-#' print("todo")
+#' aki_UO(aki_pt_data, UO = "UO_", dttm = "dttm_", pt_id = "pt_id_")
+#'
+#' aki_pt_data %>%
+#' dplyr::mutate(aki = aki_UO(UO = UO_, dttm = dttm_, pt_id = pt_id_))
aki_UO <- function(...) {
UseMethod("aki_UO")
}
#' @rdname aki_UO
#' @export
-aki_UO.default <- function(.data, UO, dttm, pt_id, ...) {
+aki_UO.data.frame <- function(.data, UO, dttm, pt_id, ...) {
ellipsis::check_dots_used()
aki_UO(
.data[[rlang::as_name(rlang::enquo(UO))]],
diff --git a/R/anemia.R b/R/anemia.R
index e50837f..f0ddfad 100644
--- a/R/anemia.R
+++ b/R/anemia.R
@@ -1,12 +1,28 @@
#' Diagnosis of anemia from Hb concentration
#'
+#' KDIGO Clinical Practice Guideline for
+#' Anemia in Chronic Kidney Disease
+#' Volume 2 | Issue 4 | August (2) 2012
+#'
+#' \itemize{
+#' \item{Adults and children >15 years with CKD when the Hb concentration is
+#' <13.0 g/dl (<130 g/l) in males and
+#' <12.0 g/dl (<120 g/l) in females.}
+#' \item{Children with CKD if Hb concentration is
+#' <11.0 g/dl (<110 g/l) in children 0.5-5 years,
+#' <11.5 g/dl (115 g/l) in children 5-12 years,
+#' and <12.0 g/dl (120 g/l) in children 12-15 years.}
+#' }
+#'
+#' See for more details.
+#'
#' @param .data (data.frame) A data.frame, optional
#' @param Hb Hemoglobin concenration
-#' column name, or vector if `.data` not provided
+#' column name, or vector of units or numeric if `.data` is not provided
#' @param age Age of patient
-#' column name, or vector if `.data` not provided
+#' column name, or vector of units or numeric if `.data` is not provided
#' @param male Male or not
-#' column name, or vector if `.data` not provided
+#' column name, or vector of logical (TRUE/FALSE) if `.data` is not provided
#' @param ... Further optional arguments
#'
#' @return Anemia
@@ -14,14 +30,17 @@
#' @export
#'
#' @examples
-#' print("todo")
+#' anemia(anemia_pt_data, Hb = "Hb", age = "age", male = "male")
+#'
+#' anemia_pt_data %>%
+#' dplyr::mutate(anemia = anemia(Hb = Hb, age = age, male = male))
anemia <- function(...) {
UseMethod("anemia")
}
#' @rdname anemia
#' @export
-anemia.default <- function(.data, Hb, age, male, ...) {
+anemia.data.frame <- function(.data, Hb, age, male, ...) {
ellipsis::check_dots_used()
anemia(
.data[[rlang::as_name(rlang::enquo(Hb))]],
diff --git a/R/ckd.R b/R/ckd.R
index c3bc902..64738b8 100644
--- a/R/ckd.R
+++ b/R/ckd.R
@@ -1,29 +1,40 @@
#' GFR Estimation
#'
-#' - 2009 CKD-EPI creatinine equation
-#' - 2012 CKD-EPI cystatin C equation
-#' - 2012 CKD-EPI creatinine-cystatin C equation
-#' - Pediatric equations
+#' Using KDIGO 2012 Clinical Practice Guideline for
+#' the Evaluation and Management of Chronic Kidney Disease
+#' Volume 3 | Issue 1 | January 2013
#'
-#' - Automatic selection of the best equation to use
+#' Automatic selection of equation to estimation the
+#' Glomerular Filtration Rate (eGFR), based on input data
+#'
+#' \itemize{
+#' \item{[`eGFR_adult_SCr()`]: 2009 CKD-EPI creatinine equation}
+#' \item{[`eGFR_adult_SCysC()`]: 2012 CKD-EPI cystatin C equation}
+#' \item{[`eGFR_adult_SCr_SCysC()`]: 2012 CKD-EPI creatinine-cystatin C equation}
+#' \item{[`eGFR_child_SCr()`]: Pediatric creatinine-based equation}
+#' \item{[`eGFR_child_SCr_BUN()`]: Pediatric creatinine-BUN equation}
+#' \item{[`eGFR_child_SCysC()`]: Pediatric cystatin C-based equation}
+#' }
+#'
+#' See for more details
#'
#' @param .data (data.frame) A data.frame, optional
#' @param SCr Serum creatinine
-#' column name, or vector if `.data` not provided
+#' column name, or vector of units or numeric if `.data` is not provided
#' @param SCysC Serum Cystatin C
-#' column name, or vector if `.data` not provided
+#' column name, or vector of units or numeric if `.data` is not provided
#' @param Age Age of patient
-#' column name, or vector if `.data` not provided
+#' column name, or vector of units or numeric if `.data` is not provided
#' @param height Height of patient
-#' column name, or vector if `.data` not provided
+#' column name, or vector of units or numeric if `.data` is not provided
#' @param BUN Blood urea nitrogen
-#' column name, or vector if `.data` not provided
+#' column name, or vector of units or numeric if `.data` is not provided
#' @param male Male or not
-#' column name, or vector if `.data` not provided
+#' column name, or vector of logical (TRUE/FALSE) if `.data` is not provided
#' @param black Black race or not
-#' column name, or vector if `.data` not provided
+#' column name, or vector of logical (TRUE/FALSE) if `.data` is not provided
#' @param pediatric (logical) Paediatric or not
-#' column name, or vector if `.data` not provided
+#' column name, or vector of logical (TRUE/FALSE) if `.data` is not provided
#' @param ... Further optional arguments
#'
#' @return (units) Estimated glomerular filtration rate (eGFR)
@@ -31,12 +42,22 @@
#' @export
#'
#' @examples
-#' print("todo")
+#' eGFR(eGFR_pt_data,
+#' SCr = "SCr_", SCysC = "SCysC_",
+#' Age = "Age_", height = "height_", BUN = "BUN_",
+#' male = "male_", black = "black_", pediatric = "pediatric_"
+#' )
+#'
+#' eGFR_pt_data %>%
+#' dplyr::mutate(eGFR = eGFR(
+#' SCr = SCr_, SCysC = SCysC_,
+#' Age = Age_, height = height_, BUN = BUN_,
+#' male = male_, black = black_, pediatric = pediatric_
+#' ))
eGFR <- function(...) {
UseMethod("eGFR")
}
-
eGFR_internal <- function(
SCr,
SCysC,
@@ -64,21 +85,20 @@ eGFR_internal <- function(
}
}
-
#' @rdname eGFR
#' @export
-eGFR.default <- function(.data,
- SCr = NULL,
- SCysC = NULL,
- Age = NULL,
- height = NULL,
- BUN = NULL,
- male = NULL,
- black = NULL,
- pediatric = NULL,
- ...) {
+eGFR.data.frame <- function(.data,
+ SCr = NULL,
+ SCysC = NULL,
+ Age = NULL,
+ height = NULL,
+ BUN = NULL,
+ male = NULL,
+ black = NULL,
+ pediatric = NULL,
+ ...) {
ellipsis::check_dots_used()
- # FIXME !is.null won't work if SCr is a symbol...
+ # [ ] !is.null won't work if SCr is a symbol...
if (!is.null(SCr)) SCr <- .data[[rlang::as_name(rlang::enquo(SCr))]]
if (!is.null(SCysC)) SCysC <- .data[[rlang::as_name(rlang::enquo(SCysC))]]
if (!is.null(Age)) Age <- .data[[rlang::as_name(rlang::enquo(Age))]]
@@ -180,22 +200,24 @@ eGFR.numeric <- function(
dplyr::pull(eGFR)
}
-# Overall GFR staging
-
-# Overall Albuminuria staging
-
-#' 2009 CKD-EPI creatinine equation
+#' eGFR 2009 CKD-EPI creatinine equation
+#'
+#' Using KDIGO 2012 Clinical Practice Guideline for
+#' the Evaluation and Management of Chronic Kidney Disease
+#' Volume 3 | Issue 1 | January 2013
+#'
+#' See for more details
#'
#' @param .data (data.frame) A data.frame, optional
#' @param SCr Serum creatinine
-#' column name, or vector if `.data` not provided
+#' column name, or vector of units or numeric if `.data` is not provided
#' @param Age Age of patient
-#' column name, or vector if `.data` not provided
+#' column name, or vector of units or numeric if `.data` is not provided
#' @param male Male or not
-#' column name, or vector if `.data` not provided
+#' column name, or vector of logical (TRUE/FALSE) if `.data` is not provided
#' @param black Black race or not
-#' column name, or vector if `.data` not provided
+#' column name, or vector of logical (TRUE/FALSE) if `.data` is not provided
#' @param ... Further optional arguments
#'
#' @return Estimated GFR
@@ -203,14 +225,21 @@ eGFR.numeric <- function(
#' @export
#'
#' @examples
-#' print("todo")
+#' eGFR_adult_SCr(eGFR_pt_data,
+#' SCr = "SCr_", Age = "Age_", male = "male_", black = "black_"
+#' )
+#'
+#' eGFR_pt_data %>%
+#' dplyr::mutate(eGFR = eGFR_adult_SCr(
+#' SCr = SCr_, Age = Age_, male = male_, black = black_
+#' ))
eGFR_adult_SCr <- function(...) {
UseMethod("eGFR_adult_SCr")
}
#' @rdname eGFR_adult_SCr
#' @export
-eGFR_adult_SCr.default <- function(.data, SCr, Age, male, black, ...) {
+eGFR_adult_SCr.data.frame <- function(.data, SCr, Age, male, black, ...) {
ellipsis::check_dots_used()
eGFR_adult_SCr(
.data[[rlang::as_name(rlang::enquo(SCr))]],
@@ -247,15 +276,21 @@ eGFR_adult_SCr.numeric <- function(SCr, Age, male, black, ...) {
}
-#' 2012 CKD-EPI cystatin C equation
+#' eGFR 2012 CKD-EPI cystatin C equation
+#'
+#' Using KDIGO 2012 Clinical Practice Guideline for
+#' the Evaluation and Management of Chronic Kidney Disease
+#' Volume 3 | Issue 1 | January 2013
+#'
+#' See for more details
#'
#' @param .data (data.frame) A data.frame, optional
#' @param SCysC Serum Cystatin C
-#' column name, or vector if `.data` not provided
+#' column name, or vector of units or numeric if `.data` is not provided
#' @param Age Age of patient
-#' column name, or vector if `.data` not provided
+#' column name, or vector of units or numeric if `.data` is not provided
#' @param male Male or not
-#' column name, or vector if `.data` not provided
+#' column name, or vector of logical (TRUE/FALSE) if `.data` is not provided
#' @param ... Further optional arguments
#'
#' @return Estimated GFR
@@ -263,14 +298,21 @@ eGFR_adult_SCr.numeric <- function(SCr, Age, male, black, ...) {
#' @export
#'
#' @examples
-#' print("todo")
+#' eGFR_adult_SCysC(eGFR_pt_data,
+#' SCysC = "SCysC_", Age = "Age_", male = "male_"
+#' )
+#'
+#' eGFR_pt_data %>%
+#' dplyr::mutate(eGFR = eGFR_adult_SCysC(
+#' SCysC = SCysC_, Age = Age_, male = male_
+#' ))
eGFR_adult_SCysC <- function(...) {
UseMethod("eGFR_adult_SCysC")
}
#' @rdname eGFR_adult_SCysC
#' @export
-eGFR_adult_SCysC.default <- function(.data, SCysC, Age, male, ...) {
+eGFR_adult_SCysC.data.frame <- function(.data, SCysC, Age, male, ...) {
ellipsis::check_dots_used()
eGFR_adult_SCysC(
.data[[rlang::as_name(rlang::enquo(SCysC))]],
@@ -301,19 +343,25 @@ eGFR_adult_SCysC.numeric <- function(SCysC, Age, male, ...) {
}
-#' 2012 CKD-EPI creatinine-cystatin C equation
+#' eGFR 2012 CKD-EPI creatinine-cystatin C equation
+#'
+#' Using KDIGO 2012 Clinical Practice Guideline for
+#' the Evaluation and Management of Chronic Kidney Disease
+#' Volume 3 | Issue 1 | January 2013
+#'
+#' See for more details
#'
#' @param .data (data.frame) A data.frame, optional
#' @param SCr Serum creatinine
-#' column name, or vector if `.data` not provided
+#' column name, or vector of units or numeric if `.data` is not provided
#' @param SCysC Serum Cystatin C
-#' column name, or vector if `.data` not provided
+#' column name, or vector of units or numeric if `.data` is not provided
#' @param Age Age of patient
-#' column name, or vector if `.data` not provided
+#' column name, or vector of units or numeric if `.data` is not provided
#' @param male Male or not
-#' column name, or vector if `.data` not provided
+#' column name, or vector of logical (TRUE/FALSE) if `.data` is not provided
#' @param black Black race or not
-#' column name, or vector if `.data` not provided
+#' column name, or vector of logical (TRUE/FALSE) if `.data` is not provided
#' @param ... Further optional arguments
#'
#' @return Estimated GFR
@@ -321,14 +369,23 @@ eGFR_adult_SCysC.numeric <- function(SCysC, Age, male, ...) {
#' @export
#'
#' @examples
-#' print("todo")
+#' eGFR_adult_SCr_SCysC(eGFR_pt_data,
+#' SCr = "SCr_", SCysC = "SCysC_",
+#' Age = "Age_", male = "male_", black = "black_"
+#' )
+#'
+#' eGFR_pt_data %>%
+#' dplyr::mutate(eGFR = eGFR_adult_SCr_SCysC(
+#' SCr = SCr_, SCysC = SCysC_,
+#' Age = Age_, male = male_, black = black_
+#' ))
eGFR_adult_SCr_SCysC <- function(...) {
UseMethod("eGFR_adult_SCr_SCysC")
}
#' @rdname eGFR_adult_SCr_SCysC
#' @export
-eGFR_adult_SCr_SCysC.default <- function(.data, SCr, SCysC, Age, male, black, ...) {
+eGFR_adult_SCr_SCysC.data.frame <- function(.data, SCr, SCysC, Age, male, black, ...) {
ellipsis::check_dots_used()
eGFR_adult_SCr_SCysC(
.data[[rlang::as_name(rlang::enquo(SCr))]],
@@ -369,13 +426,19 @@ eGFR_adult_SCr_SCysC.numeric <- function(SCr, SCysC, Age, male, black, ...) {
}
-#' Pediatric SCr and Height
+#' eGFR Pediatric SCr and Height
+#'
+#' Using KDIGO 2012 Clinical Practice Guideline for
+#' the Evaluation and Management of Chronic Kidney Disease
+#' Volume 3 | Issue 1 | January 2013
+#'
+#' See for more details
#'
#' @param .data (data.frame) A data.frame, optional
#' @param SCr Serum creatinine
-#' column name, or vector if `.data` not provided
+#' column name, or vector of units or numeric if `.data` is not provided
#' @param height Height of patient
-#' column name, or vector if `.data` not provided
+#' column name, or vector of units or numeric if `.data` is not provided
#' @param ... Further optional arguments
#'
#' @return Estimated GFR
@@ -383,14 +446,21 @@ eGFR_adult_SCr_SCysC.numeric <- function(SCr, SCysC, Age, male, black, ...) {
#' @export
#'
#' @examples
-#' print("todo")
+#' eGFR_child_SCr(eGFR_pt_data,
+#' SCr = "SCr_", height = "height_"
+#' )
+#'
+#' eGFR_pt_data %>%
+#' dplyr::mutate(eGFR = eGFR_child_SCr(
+#' SCr = SCr_, height = height_,
+#' ))
eGFR_child_SCr <- function(...) {
UseMethod("eGFR_child_SCr")
}
#' @rdname eGFR_child_SCr
#' @export
-eGFR_child_SCr.default <- function(.data, SCr, height, ...) {
+eGFR_child_SCr.data.frame <- function(.data, SCr, height, ...) {
ellipsis::check_dots_used()
eGFR_child_SCr(
.data[[rlang::as_name(rlang::enquo(SCr))]],
@@ -417,15 +487,21 @@ eGFR_child_SCr.numeric <- function(SCr, height, ...) {
}
-#' Pediatric SCr, Height and BUN
+#' eGFR Pediatric SCr, Height and BUN
+#'
+#' Using KDIGO 2012 Clinical Practice Guideline for
+#' the Evaluation and Management of Chronic Kidney Disease
+#' Volume 3 | Issue 1 | January 2013
+#'
+#' See for more details
#'
#' @param .data (data.frame) A data.frame, optional
#' @param SCr Serum creatinine
-#' column name, or vector if `.data` not provided
+#' column name, or vector of units or numeric if `.data` is not provided
#' @param height Height of patient
-#' column name, or vector if `.data` not provided
+#' column name, or vector of units or numeric if `.data` is not provided
#' @param BUN Blood urea nitrogen
-#' column name, or vector if `.data` not provided
+#' column name, or vector of units or numeric if `.data` is not provided
#' @param ... Further optional arguments
#'
#' @return Estimated GFR
@@ -433,14 +509,21 @@ eGFR_child_SCr.numeric <- function(SCr, height, ...) {
#' @export
#'
#' @examples
-#' print("todo")
+#' eGFR_child_SCr_BUN(eGFR_pt_data,
+#' SCr = "SCr_", height = "height_", BUN = "BUN_",
+#' )
+#'
+#' eGFR_pt_data %>%
+#' dplyr::mutate(eGFR = eGFR_child_SCr_BUN(
+#' SCr = SCr_, height = height_, BUN = BUN_,
+#' ))
eGFR_child_SCr_BUN <- function(...) {
UseMethod("eGFR_child_SCr_BUN")
}
#' @rdname eGFR_child_SCr_BUN
#' @export
-eGFR_child_SCr_BUN.default <- function(.data, SCr, height, BUN, ...) {
+eGFR_child_SCr_BUN.data.frame <- function(.data, SCr, height, BUN, ...) {
ellipsis::check_dots_used()
eGFR_child_SCr_BUN(
.data[[rlang::as_name(rlang::enquo(SCr))]],
@@ -469,11 +552,17 @@ eGFR_child_SCr_BUN.numeric <- function(SCr, height, BUN, ...) {
}
-#' Pediatric SCysC
+#' eGFR Pediatric SCysC
+#'
+#' Using KDIGO 2012 Clinical Practice Guideline for
+#' the Evaluation and Management of Chronic Kidney Disease
+#' Volume 3 | Issue 1 | January 2013
+#'
+#' See for more details
#'
#' @param .data (data.frame) A data.frame, optional
#' @param SCysC Serum Cystatin C
-#' column name, or vector if `.data` not provided
+#' column name, or vector of units or numeric if `.data` is not provided
#' @param ... Further optional arguments
#'
#' @return Estimated GFR
@@ -481,14 +570,21 @@ eGFR_child_SCr_BUN.numeric <- function(SCr, height, BUN, ...) {
#' @export
#'
#' @examples
-#' print("todo")
+#' eGFR_child_SCysC(eGFR_pt_data,
+#' SCysC = "SCysC_"
+#' )
+#'
+#' eGFR_pt_data %>%
+#' dplyr::mutate(eGFR = eGFR_child_SCysC(
+#' SCysC = SCysC_
+#' ))
eGFR_child_SCysC <- function(...) {
UseMethod("eGFR_child_SCysC")
}
#' @rdname eGFR_child_SCysC
#' @export
-eGFR_child_SCysC.default <- function(.data, SCysC, ...) {
+eGFR_child_SCysC.data.frame <- function(.data, SCysC, ...) {
ellipsis::check_dots_used()
eGFR_child_SCysC(
.data[[rlang::as_name(rlang::enquo(SCysC))]]
@@ -517,6 +613,8 @@ eGFR_child_SCysC.numeric <- function(SCysC, ...) {
#'
#' Ordered factor of GFR stages
#'
+#' See for more details
+#'
#' @export
#' @examples
#' GFR_stages
@@ -525,23 +623,45 @@ GFR_stages <- factor(c("G1", "G2", "G3a", "G3b", "G4", "G5"), ordered = TRUE)
#' GFR Staging
#'
+#' Using KDIGO 2012 Clinical Practice Guideline for
+#' the Evaluation and Management of Chronic Kidney Disease
+#' Volume 3 | Issue 1 | January 2013
+#'
+#' \itemize{
+#' \item{G1: Normal or high GFR, \eqn{\ge}90}
+#' \item{G2: Mildly decreased, 60-89}
+#' \item{G3a: Mildly to moderately decreased, 45-59}
+#' \item{G3b: Moderately to severely decreased, 30-44}
+#' \item{G4: Severely decreased, 15-29}
+#' \item{G5: Kidney failure, <15}
+#' }
+#'
+#' See for more details
+#'
#' @param .data (data.frame) A data.frame, optional
#' @param GFR Glomerular filtration rate
-#' column name, or vector if `.data` not provided
+#' column name, or vector of units or numeric if `.data` is not provided
#' @param ... Further optional arguments
#'
#' @return GFR category
#' @export
#'
#' @examples
-#' print("todo")
+#' df <- tibble::tibble(
+#' eGFR = units::set_units(c(-1, NA, 100, 70, 50, 35, 20, 10), "mL/min/1.73m2")
+#' )
+#'
+#' GFR_staging(df, "eGFR")
+#'
+#' df %>%
+#' dplyr::mutate(GFR_level = GFR_staging(eGFR))
GFR_staging <- function(...) {
UseMethod("GFR_staging")
}
#' @rdname GFR_staging
#' @export
-GFR_staging.default <- function(.data, GFR, ...) {
+GFR_staging.data.frame <- function(.data, GFR, ...) {
GFR_staging(
.data[[rlang::as_name(rlang::enquo(GFR))]]
)
@@ -577,6 +697,14 @@ GFR_staging.numeric <- function(GFR, ...) {
#'
#' Ordered factor of Albuminuria stages
#'
+#' \itemize{
+#' \item{A1: Normal to mildly increased}
+#' \item{A2: Moderately increased}
+#' \item{A3: Severely increased}
+#' }
+#'
+#' See for more details
+#'
#' @export
#' @examples
#' Albuminuria_stages
@@ -589,23 +717,42 @@ Albuminuria_stages <- factor(
#' Albuminuria Staging based on AER
#'
+#' Using KDIGO 2012 Clinical Practice Guideline for
+#' the Evaluation and Management of Chronic Kidney Disease
+#' Volume 3 | Issue 1 | January 2013
+#'
+#' \itemize{
+#' \item{A1: Normal to mildly increased}
+#' \item{A2: Moderately increased}
+#' \item{A3: Severely increased}
+#' }
+#'
+#' See for more details
+#'
#' @param .data (data.frame) A data.frame, optional
#' @param AER Albumin excretion rate
-#' column name, or vector if `.data` not provided
+#' column name, or vector of units or numeric if `.data` is not provided
#' @param ... Further optional arguments
#'
#' @return Albuminuria category
#' @export
#'
#' @examples
-#' print("todo")
+#' df <- tibble::tibble(
+#' AER = units::set_units(c(-1, NA, 15, 100, 500), "mg/day")
+#' )
+#'
+#' Albuminuria_staging_AER(df, "AER")
+#'
+#' df %>%
+#' dplyr::mutate(GFR_level = Albuminuria_staging_AER(AER))
Albuminuria_staging_AER <- function(...) {
UseMethod("Albuminuria_staging_AER")
}
#' @rdname Albuminuria_staging_AER
#' @export
-Albuminuria_staging_AER.default <- function(.data, AER, ...) {
+Albuminuria_staging_AER.data.frame <- function(.data, AER, ...) {
Albuminuria_staging_AER(
.data[[rlang::as_name(rlang::enquo(AER))]]
)
@@ -633,23 +780,42 @@ Albuminuria_staging_AER.numeric <- function(AER, ...) {
#' Albuminuria Staging based on ACR
#'
+#' Using KDIGO 2012 Clinical Practice Guideline for
+#' the Evaluation and Management of Chronic Kidney Disease
+#' Volume 3 | Issue 1 | January 2013
+#'
+#' \itemize{
+#' \item{A1: Normal to mildly increased}
+#' \item{A2: Moderately increased}
+#' \item{A3: Severely increased}
+#' }
+#'
+#' See for more details
+#'
#' @param .data (data.frame) A data.frame, optional
#' @param ACR Albumin-to-creatinine ratio
-#' column name, or vector if `.data` not provided
+#' column name, or vector of units or numeric if `.data` is not provided
#' @param ... Further optional arguments
#'
#' @return Albuminuria category
#' @export
#'
#' @examples
-#' print("todo")
+#' df <- tibble::tibble(
+#' ACR = units::set_units(c(-1, NA, 1, 10, 50), "mg/g")
+#' )
+#'
+#' Albuminuria_staging_ACR(df, "ACR")
+#'
+#' df %>%
+#' dplyr::mutate(GFR_level = Albuminuria_staging_ACR(ACR))
Albuminuria_staging_ACR <- function(...) {
UseMethod("Albuminuria_staging_ACR")
}
#' @rdname Albuminuria_staging_ACR
#' @export
-Albuminuria_staging_ACR.default <- function(.data, ACR, ...) {
+Albuminuria_staging_ACR.data.frame <- function(.data, ACR, ...) {
Albuminuria_staging_ACR(
.data[[rlang::as_name(rlang::enquo(ACR))]]
)
diff --git a/R/data-aki.R b/R/data-aki.R
new file mode 100644
index 0000000..9b7a9b3
--- /dev/null
+++ b/R/data-aki.R
@@ -0,0 +1,7 @@
+#' AKI Patient Data
+#'
+#' A sample dataset to demonstrate calculating AKI with `epocakir`
+#'
+#' @examples
+#' aki_pt_data
+"aki_pt_data"
diff --git a/R/data-anemia.R b/R/data-anemia.R
new file mode 100644
index 0000000..342f9c2
--- /dev/null
+++ b/R/data-anemia.R
@@ -0,0 +1,7 @@
+#' Anemia Patient Data
+#'
+#' A sample dataset to demonstrate calculating anemia with `epocakir`
+#'
+#' @examples
+#' anemia_pt_data
+"anemia_pt_data"
diff --git a/R/data-eGFR.R b/R/data-eGFR.R
new file mode 100644
index 0000000..be0e56d
--- /dev/null
+++ b/R/data-eGFR.R
@@ -0,0 +1,7 @@
+#' eGFR Patient Data
+#'
+#' A sample dataset to demonstrate calculating eGFR with `epocakir`
+#'
+#' @examples
+#' eGFR_pt_data
+"eGFR_pt_data"
diff --git a/R/hep-c.R b/R/hep-c.R
index f58fb39..e74fb23 100644
--- a/R/hep-c.R
+++ b/R/hep-c.R
@@ -1 +1 @@
-# Albuminuria categories
+# NULL
diff --git a/R/lipid.R b/R/lipid.R
index 00ffcc6..c353174 100644
--- a/R/lipid.R
+++ b/R/lipid.R
@@ -1,2 +1,2 @@
# NULL
-# conversion of cholesterol, triglycerides, etc
+# [ ]: conversion of cholesterol, triglycerides, etc
diff --git a/R/utils.R b/R/utils.R
index ff6fa95..cbf5a20 100644
--- a/R/utils.R
+++ b/R/utils.R
@@ -11,10 +11,6 @@
NULL
-# TODO consider adding a set_metric() and set_SI() which are simple
-# wrappers to convert data.frame columns into units
-
-
#' Conversion Factors
#'
#' List of conversion factors based on tables in KDIGO Clinical Practice
@@ -87,7 +83,7 @@ as_metric <- function(param = NULL, meas = NULL, ..., value_only = FALSE) {
elli <- list(...)
if (length(elli) == 0) {
return(NULL)
- } # as_metric(1) will return NULL, no warning
+ } # as_metric(1) will return NULL with no warning
param <- names(elli)[1]
meas <- elli[[1]]
}
@@ -186,6 +182,7 @@ binary2factor <- function(.data, ...) {
)
}
+# Internal helper functions for combine_date_time_cols
set_names <- function(.data, names) {
names(.data) <- names
.data
@@ -212,7 +209,14 @@ find_cols <- function(text, replace, colnames) {
#' @export
#'
#' @examples
-#' print("todo")
+#' df <- data.frame(
+#' date_a = as.Date(c("2020-01-01", "2020-01-02")),
+#' date_b = as.POSIXct(c("2020-02-01", "2020-02-02")),
+#' time_a = as.POSIXct(c("1900-01-01 01:01:01", "1900-01-01 02:02:02")),
+#' time_b = as.POSIXct(c("1900-01-01 01:01:01", "1900-01-01 02:02:02"))
+#' )
+#'
+#' combine_date_time_cols(df)
combine_date_time_cols <- function(.data, tz = NULL) {
dttm_col <- dplyr::inner_join(
find_cols("date", "DateTime", colnames(.data)),
@@ -267,15 +271,15 @@ combine_date_time_cols <- function(.data, tz = NULL) {
#' Combinatorics changes
#'
-#' Compares a value with previous values
+#' Compares a value with all previous values
#'
#' @param .data (data.frame) A data.frame, optional
#' @param dttm DateTime
-#' column name, or vector if `.data` not provided
+#' column name, or vector of POSIXct if `.data` is not provided
#' @param val Variable
-#' column name, or vector if `.data` not provided
+#' column name, or vector of units or numeric if `.data` is not provided
#' @param pt_id Patient ID
-#' column name, or vector if `.data` not provided
+#' column name, or vector of characters or factors if `.data` is not provided
#' @param ... Further optional arguments
#'
#' @return Combinatorics changes
@@ -283,14 +287,17 @@ combine_date_time_cols <- function(.data, tz = NULL) {
#' @export
#'
#' @examples
-#' print("todo")
+#' combn_changes(aki_pt_data, dttm = "dttm_", val = "SCr_", pt_id = "pt_id_")
+#'
+#' aki_pt_data %>%
+#' combn_changes(dttm_, SCr_, pt_id_)
combn_changes <- function(...) {
UseMethod("combn_changes")
}
#' @rdname combn_changes
#' @export
-combn_changes.default <- function(.data, dttm, val, pt_id, ...) {
+combn_changes.data.frame <- function(.data, dttm, val, pt_id, ...) {
ellipsis::check_dots_used()
val_name <- rlang::as_name(rlang::enquo(val))
dttm_name <- rlang::as_name(rlang::enquo(dttm))
@@ -307,10 +314,6 @@ combn_changes.default <- function(.data, dttm, val, pt_id, ...) {
return(data_n)
}
-# TODO: The group_by could be done outside of the function?
-# e.g. df %>% group_by(pt_id) %>% combn_changes(dttm, val)
-# TODO: Consider making .data.frame as the function. POSIXct creates a
-# tibble and then sends it to combn_changes
#' @rdname combn_changes
#' @export
combn_changes.POSIXct <- function(dttm, val, pt_id, ...) {
@@ -321,7 +324,7 @@ combn_changes.POSIXct <- function(dttm, val, pt_id, ...) {
) %>%
dplyr::group_by(.data$pt_id, .add = FALSE) %>%
dplyr::arrange(.data$pt_id, .data$dttm) %>%
- unique() %>%
+ dplyr::distinct() %>%
dplyr::mutate(
admin = cumsum(
(dttm - dplyr::lag(dttm, default = lubridate::as_date(0))) >=
@@ -330,18 +333,19 @@ combn_changes.POSIXct <- function(dttm, val, pt_id, ...) {
) %>%
tidyr::drop_na() %>%
dplyr::group_by(.data$admin, .add = TRUE)
- # check for nrow < 2
+
data_n <- data_gr %>%
dplyr::count() %>%
+ dplyr::filter(.data$n > 1) %>% # prevent n < m error in combn
dplyr::ungroup() %>%
dplyr::mutate(n_1 = cumsum(dplyr::lag(.data$n, default = 0))) %>%
dplyr::rowwise() %>%
dplyr::do(data.frame(.data$n_1 + t(utils::combn(.data$n, 2)))) %>%
dplyr::arrange(.data$X2, dplyr::desc(.data$X1))
- # consider a more dplyr version e.g. pivot_longer (X1, X2) then use summarise and diff
+ # [ ]: consider a more dplyr version e.g. pivot_longer (X1, X2) then use summarise and diff
T1 <- data_gr[data_n$X1, ]
T2 <- data_gr[data_n$X2, ]
- # The patient id should also match, remove after testing
+ # The patient id should also match, remove in future if warning never raised
if (!all.equal(T1[c("pt_id", "admin")], T2[c("pt_id", "admin")])) {
warning("Unexpected mismatch in patient ids") # nocov
}
@@ -354,5 +358,5 @@ combn_changes.POSIXct <- function(dttm, val, pt_id, ...) {
D.dttm = T2$dttm - T1$dttm
) %>%
dplyr::filter(.data$D.dttm <= lubridate::duration(hours = 48)) %>%
- dplyr::select(.data$pt_id, .data$dttm:.data$D.dttm) # %>%
+ dplyr::select(.data$pt_id, .data$dttm:.data$D.dttm)
}
diff --git a/data-raw/aki-data.R b/data-raw/aki-data.R
new file mode 100644
index 0000000..5877e96
--- /dev/null
+++ b/data-raw/aki-data.R
@@ -0,0 +1,109 @@
+aki_stages <- factor(
+ c("AKI Stage 1", "AKI Stage 2", "AKI Stage 3", "No AKI"),
+ levels = c("No AKI", "AKI Stage 1", "AKI Stage 2", "AKI Stage 3"),
+ ordered = TRUE
+)
+
+aki_bCr_test_df <- function(env = parent.frame()) {
+ tibble::tibble(
+ SCr_ = units::set_units(seq(2.0, 4.5, by = 0.5), "mg/dl"),
+ bCr_ = units::set_units(1.5, "mg/dl"),
+ aki_bCr = vctrs::vec_c(
+ dplyr::last(aki_stages),
+ aki_stages[1],
+ aki_stages[2],
+ aki_stages[2],
+ aki_stages[3],
+ aki_stages[3]
+ )
+ )
+}
+
+aki_SCr_test_raw_df <- function(env = parent.frame()) {
+ tibble::tibble(
+ pt_id_ = c(rep("pt1", 3 + 3), rep("pt2", 3)),
+ dttm_ = c(
+ seq(
+ lubridate::as_datetime("2020-10-18 09:00:00", tz = "Australia/Melbourne"),
+ lubridate::as_datetime("2020-10-20 09:00:00", tz = "Australia/Melbourne"),
+ length.out = 3
+ ),
+ seq(
+ lubridate::as_datetime("2020-10-23 09:00:00", tz = "Australia/Melbourne"),
+ lubridate::as_datetime("2020-10-25 21:00:00", tz = "Australia/Melbourne"),
+ length.out = 3
+ ),
+ seq(
+ lubridate::as_datetime("2020-10-18 10:00:00", tz = "Australia/Melbourne"),
+ lubridate::as_datetime("2020-10-19 10:00:00", tz = "Australia/Melbourne"),
+ length.out = 3
+ )
+ ),
+ SCr_ = c(
+ units::set_units(seq(2.0, 3.0, by = 0.5), "mg/dl"),
+ units::set_units(seq(3.4, 3.9, by = 0.25), "mg/dl"),
+ units::set_units(seq(3.3, 3.5, by = 0.10), "mg/dl")
+ ),
+ bCr_ = c(
+ rep(units::set_units(1.8, "mg/dl"), 3 + 3),
+ rep(units::set_units(3.0, "mg/dl"), 3)
+ ),
+ aki_SCr = vctrs::vec_c(
+ dplyr::last(aki_stages),
+ rep(aki_stages[1], 2),
+ rep(dplyr::last(aki_stages), 6)
+ )
+ )
+}
+
+aki_SCr_test_rand_df <- function(env = parent.frame()) {
+ aki_SCr_test_raw_df()[c(4, 6, 3, 8, 1, 2, 7, 9, 5), ]
+}
+
+aki_UO_test_raw_df <- function(env = parent.frame()) {
+ tibble::tribble(
+ ~pt_id_, ~dttm_, ~UO_, ~aki_UO,
+ 3, "2020-10-18 09:00:00", 8, 4,
+ 3, "2020-10-18 15:00:00", 5, 4,
+ 3, "2020-10-18 21:00:00", 2, 1,
+ 3, "2020-10-19 01:00:00", 1, 1,
+ 3, "2020-10-19 03:00:00", 1, 2,
+ 3, "2020-10-19 09:00:00", 1, 2,
+ 3, "2020-10-19 15:00:00", 1, 3,
+ 3, "2020-10-19 21:00:00", 1, 3,
+ 4, "2020-10-18 12:00:00", 2, 4,
+ 4, "2020-10-18 18:00:00", 0, 1,
+ 4, "2020-10-19 00:00:00", 0, 3,
+ 4, "2020-10-19 06:00:00", 0, 3,
+ ) %>%
+ dplyr::mutate(
+ pt_id_ = paste0("pt", pt_id_),
+ dttm_ = lubridate::as_datetime(dttm_, tz = "Australia/Melbourne"),
+ UO_ = units::set_units(UO_, "ml/kg"),
+ aki_UO = aki_stages[aki_UO]
+ )
+}
+
+aki_UO_test_rand_df <- function(env = parent.frame()) {
+ aki_UO_test_raw_df()[c(10, 9, 5, 8, 3, 11, 6, 2, 4, 12, 7, 1), ]
+}
+
+aki_test_df <- function(env = parent.frame()) {
+ dplyr::bind_rows(aki_bCr_test_df(), aki_SCr_test_rand_df(), aki_UO_test_rand_df()) %>%
+ tidyr::pivot_longer(
+ dplyr::starts_with("aki_"),
+ names_to = "aki_staging_type",
+ values_to = "aki_"
+ ) %>%
+ dplyr::mutate(
+ SCr_ = dplyr::if_else(grepl("bCr|SCr", aki_staging_type), SCr_, NA_real_),
+ bCr_ = dplyr::if_else(grepl("bCr", aki_staging_type), bCr_, NA_real_),
+ UO_ = dplyr::if_else(grepl("UO", aki_staging_type), UO_, NA_real_)
+ ) %>%
+ dplyr::filter(!is.na(aki_))
+}
+
+# Consider finding an alternative with real, open access data instead
+aki_pt_data <- aki_test_df()
+
+usethis::use_data(aki_pt_data, overwrite = TRUE)
diff --git a/data-raw/anemia-data.R b/data-raw/anemia-data.R
new file mode 100644
index 0000000..ac91f9f
--- /dev/null
+++ b/data-raw/anemia-data.R
@@ -0,0 +1,24 @@
+anemia_df <- function(env = parent.frame()) {
+ tibble::tribble(
+ ~Hb, ~age, ~male,
+ 12.5, 20, TRUE,
+ 13.5, 20, TRUE,
+ 11.5, 20, FALSE,
+ 12.5, 20, FALSE,
+ 11.5, 13, TRUE,
+ 12.5, 13, TRUE,
+ 11.0, 7, TRUE,
+ 12.0, 7, TRUE,
+ 10.5, 3, TRUE,
+ 11.5, 3, TRUE,
+ ) %>%
+ dplyr::mutate(
+ Hb = units::set_units(Hb, "g/dl"),
+ age = units::set_units(age, "years")
+ )
+}
+
+# Consider finding an alternative with real, open access data instead
+anemia_pt_data <- anemia_df()
+
+usethis::use_data(anemia_pt_data, overwrite = TRUE)
diff --git a/data-raw/eGFR-data.R b/data-raw/eGFR-data.R
new file mode 100644
index 0000000..818ae6d
--- /dev/null
+++ b/data-raw/eGFR-data.R
@@ -0,0 +1,122 @@
+eGFR_adult_df <- function(env = parent.frame()) {
+ tibble::tribble(
+ ~SCr, ~SCysC, ~Age, ~male, ~black,
+ 0.5, 0.4, 20, FALSE, FALSE,
+ 0.5, 0.4, 30, FALSE, TRUE,
+ 0.5, 1.2, 20, FALSE, FALSE,
+ 0.5, 1.2, 30, FALSE, TRUE,
+ 1.5, 0.4, 20, FALSE, FALSE,
+ 1.5, 0.4, 30, FALSE, TRUE,
+ 1.5, 1.2, 20, FALSE, FALSE,
+ 1.5, 1.2, 30, FALSE, TRUE,
+ 0.5, 0.4, 20, TRUE, FALSE,
+ 0.5, 0.4, 30, TRUE, TRUE,
+ 0.5, 1.2, 20, TRUE, FALSE,
+ 0.5, 1.2, 30, TRUE, TRUE,
+ 1.5, 0.4, 20, TRUE, FALSE,
+ 1.5, 0.4, 30, TRUE, TRUE,
+ 1.5, 1.2, 20, TRUE, FALSE,
+ 1.5, 1.2, 30, TRUE, TRUE
+ ) %>%
+ dplyr::mutate(
+ SCr = units::set_units(SCr, "mg/dl"),
+ SCysC = units::set_units(SCysC, "mg/l"),
+ Age = units::set_units(Age, "years")
+ ) %>%
+ tibble::add_column(
+ eGFR_adult_SCr = c(
+ rep(c(
+ 143.5 * (0.5 / 0.7)^-0.329 * 0.993^20,
+ 143.5 * (0.5 / 0.7)^-0.329 * 0.993^30 * 1.159
+ ), 2),
+ rep(c(
+ 143.5 * (1.5 / 0.7)^-1.209 * 0.993^20,
+ 143.5 * (1.5 / 0.7)^-1.209 * 0.993^30 * 1.159
+ ), 2),
+ rep(c(
+ 141 * (0.5 / 0.9)^-0.411 * 0.993^20,
+ 141 * (0.5 / 0.9)^-0.411 * 0.993^30 * 1.159
+ ), 2),
+ rep(c(
+ 141 * (1.5 / 0.9)^-1.209 * 0.993^20,
+ 141 * (1.5 / 0.9)^-1.209 * 0.993^30 * 1.159
+ ), 2)
+ ),
+ eGFR_adult_SCysC = c(
+ rep(c(
+ 133 * (0.4 / 0.8)^-0.499 * 0.996^20 * 0.932,
+ 133 * (0.4 / 0.8)^-0.499 * 0.996^30 * 0.932,
+ 133 * (1.2 / 0.8)^-1.328 * 0.996^20 * 0.932,
+ 133 * (1.2 / 0.8)^-1.328 * 0.996^30 * 0.932
+ ), 2),
+ rep(c(
+ 133 * (0.4 / 0.8)^-0.499 * 0.996^20,
+ 133 * (0.4 / 0.8)^-0.499 * 0.996^30,
+ 133 * (1.2 / 0.8)^-1.328 * 0.996^20,
+ 133 * (1.2 / 0.8)^-1.328 * 0.996^30
+ ), 2)
+ ),
+ eGFR_adult_SCr_SCysC = c(
+ 130.8 * (0.5 / 0.7)^-0.248 * (0.4 / 0.8)^-0.375 * 0.995^20,
+ 130.8 * (0.5 / 0.7)^-0.248 * (0.4 / 0.8)^-0.375 * 0.995^30 * 1.08,
+ 130.8 * (0.5 / 0.7)^-0.248 * (1.2 / 0.8)^-0.711 * 0.995^20,
+ 130.8 * (0.5 / 0.7)^-0.248 * (1.2 / 0.8)^-0.711 * 0.995^30 * 1.08,
+ 130.8 * (1.5 / 0.7)^-0.601 * (0.4 / 0.8)^-0.375 * 0.995^20,
+ 130.8 * (1.5 / 0.7)^-0.601 * (0.4 / 0.8)^-0.375 * 0.995^30 * 1.08,
+ 130.8 * (1.5 / 0.7)^-0.601 * (1.2 / 0.8)^-0.711 * 0.995^20,
+ 130.8 * (1.5 / 0.7)^-0.601 * (1.2 / 0.8)^-0.711 * 0.995^30 * 1.08,
+ 135 * (0.5 / 0.9)^-0.207 * (0.4 / 0.8)^-0.375 * 0.995^20,
+ 135 * (0.5 / 0.9)^-0.207 * (0.4 / 0.8)^-0.375 * 0.995^30 * 1.08,
+ 135 * (0.5 / 0.9)^-0.207 * (1.2 / 0.8)^-0.711 * 0.995^20,
+ 135 * (0.5 / 0.9)^-0.207 * (1.2 / 0.8)^-0.711 * 0.995^30 * 1.08,
+ 135 * (1.5 / 0.9)^-0.601 * (0.4 / 0.8)^-0.375 * 0.995^20,
+ 135 * (1.5 / 0.9)^-0.601 * (0.4 / 0.8)^-0.375 * 0.995^30 * 1.08,
+ 135 * (1.5 / 0.9)^-0.601 * (1.2 / 0.8)^-0.711 * 0.995^20,
+ 135 * (1.5 / 0.9)^-0.601 * (1.2 / 0.8)^-0.711 * 0.995^30 * 1.08
+ )
+ ) %>%
+ dplyr::mutate(dplyr::across(
+ dplyr::starts_with("eGFR"), units::set_units, "mL/min/1.73m2"
+ ))
+}
+
+eGFR_child_df <- function(env = parent.frame()) {
+ tibble::tibble(
+ SCr = units::set_units(0.5, "mg/dl"),
+ height = units::set_units(1.2, "m"),
+ BUN = units::set_units(0.8, "mg/dl"),
+ SCysC = units::set_units(0.4, "mg/l")
+ ) %>%
+ tibble::add_column(
+ eGFR_child_SCr = 41.3 * (1.2 / 0.5),
+ eGFR_child_SCr_BUN = 40.7 * (1.2 / 0.5)^0.64 * (30 / 0.8)^0.202,
+ eGFR_child_SCysC = 70.69 * (0.4)^-0.931
+ ) %>%
+ dplyr::mutate(dplyr::across(
+ dplyr::starts_with("eGFR"), units::set_units, "mL/min/1.73m2"
+ ))
+}
+
+eGFR_df <- function(env = parent.frame()) {
+ dplyr::bind_rows(eGFR_adult_df(), eGFR_child_df()) %>%
+ tidyr::pivot_longer(
+ dplyr::starts_with("eGFR_"),
+ names_to = "eGFR_calc_type",
+ values_to = "eGFR"
+ ) %>%
+ dplyr::mutate(
+ pediatric = grepl("child", eGFR_calc_type),
+ SCr = dplyr::if_else(grepl("SCr", eGFR_calc_type), SCr, NA_real_),
+ SCysC = dplyr::if_else(grepl("SCysC", eGFR_calc_type), SCysC, NA_real_),
+ BUN = dplyr::if_else(grepl("BUN", eGFR_calc_type), BUN, NA_real_),
+ Age = dplyr::if_else(pediatric, units::set_units(10, "years"), Age)
+ ) %>%
+ dplyr::filter(!is.na(eGFR)) %>%
+ dplyr::rename_with(~ paste0(.x, "_"))
+}
+
+
+# Consider finding an alternative with real, open access data instead
+eGFR_pt_data <- eGFR_df()
+
+usethis::use_data(eGFR_pt_data, overwrite = TRUE)
diff --git a/data/aki_pt_data.rda b/data/aki_pt_data.rda
new file mode 100644
index 0000000..dba33a5
Binary files /dev/null and b/data/aki_pt_data.rda differ
diff --git a/data/anemia_pt_data.rda b/data/anemia_pt_data.rda
new file mode 100644
index 0000000..fa7e1ab
Binary files /dev/null and b/data/anemia_pt_data.rda differ
diff --git a/data/eGFR_pt_data.rda b/data/eGFR_pt_data.rda
new file mode 100644
index 0000000..4e65051
Binary files /dev/null and b/data/eGFR_pt_data.rda differ
diff --git a/man/Albuminuria_stages.Rd b/man/Albuminuria_stages.Rd
index 3c72941..7f9cfcb 100644
--- a/man/Albuminuria_stages.Rd
+++ b/man/Albuminuria_stages.Rd
@@ -13,6 +13,15 @@ Albuminuria_stages
\description{
Ordered factor of Albuminuria stages
}
+\details{
+\itemize{
+\item{A1: Normal to mildly increased}
+\item{A2: Moderately increased}
+\item{A3: Severely increased}
+}
+
+See \url{https://kdigo.org/guidelines/ckd-evaluation-and-management/} for more details
+}
\examples{
Albuminuria_stages
}
diff --git a/man/Albuminuria_staging_ACR.Rd b/man/Albuminuria_staging_ACR.Rd
index e6397c1..1de7315 100644
--- a/man/Albuminuria_staging_ACR.Rd
+++ b/man/Albuminuria_staging_ACR.Rd
@@ -2,14 +2,14 @@
% Please edit documentation in R/ckd.R
\name{Albuminuria_staging_ACR}
\alias{Albuminuria_staging_ACR}
-\alias{Albuminuria_staging_ACR.default}
+\alias{Albuminuria_staging_ACR.data.frame}
\alias{Albuminuria_staging_ACR.units}
\alias{Albuminuria_staging_ACR.numeric}
\title{Albuminuria Staging based on ACR}
\usage{
Albuminuria_staging_ACR(...)
-\method{Albuminuria_staging_ACR}{default}(.data, ACR, ...)
+\method{Albuminuria_staging_ACR}{data.frame}(.data, ACR, ...)
\method{Albuminuria_staging_ACR}{units}(ACR, ...)
@@ -21,14 +21,32 @@ Albuminuria_staging_ACR(...)
\item{.data}{(data.frame) A data.frame, optional}
\item{ACR}{Albumin-to-creatinine ratio
-column name, or vector if \code{.data} not provided}
+column name, or vector of units or numeric if \code{.data} is not provided}
}
\value{
Albuminuria category
}
\description{
-Albuminuria Staging based on ACR
+Using KDIGO 2012 Clinical Practice Guideline for
+the Evaluation and Management of Chronic Kidney Disease
+Volume 3 | Issue 1 | January 2013
+}
+\details{
+\itemize{
+\item{A1: Normal to mildly increased}
+\item{A2: Moderately increased}
+\item{A3: Severely increased}
+}
+
+See \url{https://kdigo.org/guidelines/ckd-evaluation-and-management/} for more details
}
\examples{
-print("todo")
+df <- tibble::tibble(
+ ACR = units::set_units(c(-1, NA, 1, 10, 50), "mg/g")
+)
+
+Albuminuria_staging_ACR(df, "ACR")
+
+df \%>\%
+ dplyr::mutate(GFR_level = Albuminuria_staging_ACR(ACR))
}
diff --git a/man/Albuminuria_staging_AER.Rd b/man/Albuminuria_staging_AER.Rd
index c94df2d..3ea7070 100644
--- a/man/Albuminuria_staging_AER.Rd
+++ b/man/Albuminuria_staging_AER.Rd
@@ -2,14 +2,14 @@
% Please edit documentation in R/ckd.R
\name{Albuminuria_staging_AER}
\alias{Albuminuria_staging_AER}
-\alias{Albuminuria_staging_AER.default}
+\alias{Albuminuria_staging_AER.data.frame}
\alias{Albuminuria_staging_AER.units}
\alias{Albuminuria_staging_AER.numeric}
\title{Albuminuria Staging based on AER}
\usage{
Albuminuria_staging_AER(...)
-\method{Albuminuria_staging_AER}{default}(.data, AER, ...)
+\method{Albuminuria_staging_AER}{data.frame}(.data, AER, ...)
\method{Albuminuria_staging_AER}{units}(AER, ...)
@@ -21,14 +21,32 @@ Albuminuria_staging_AER(...)
\item{.data}{(data.frame) A data.frame, optional}
\item{AER}{Albumin excretion rate
-column name, or vector if \code{.data} not provided}
+column name, or vector of units or numeric if \code{.data} is not provided}
}
\value{
Albuminuria category
}
\description{
-Albuminuria Staging based on AER
+Using KDIGO 2012 Clinical Practice Guideline for
+the Evaluation and Management of Chronic Kidney Disease
+Volume 3 | Issue 1 | January 2013
+}
+\details{
+\itemize{
+\item{A1: Normal to mildly increased}
+\item{A2: Moderately increased}
+\item{A3: Severely increased}
+}
+
+See \url{https://kdigo.org/guidelines/ckd-evaluation-and-management/} for more details
}
\examples{
-print("todo")
+df <- tibble::tibble(
+ AER = units::set_units(c(-1, NA, 15, 100, 500), "mg/day")
+)
+
+Albuminuria_staging_AER(df, "AER")
+
+df \%>\%
+ dplyr::mutate(GFR_level = Albuminuria_staging_AER(AER))
}
diff --git a/man/GFR_stages.Rd b/man/GFR_stages.Rd
index 3ab27ba..6bc15f8 100644
--- a/man/GFR_stages.Rd
+++ b/man/GFR_stages.Rd
@@ -13,6 +13,9 @@ GFR_stages
\description{
Ordered factor of GFR stages
}
+\details{
+See \url{https://kdigo.org/guidelines/ckd-evaluation-and-management/} for more details
+}
\examples{
GFR_stages
}
diff --git a/man/GFR_staging.Rd b/man/GFR_staging.Rd
index 67b5c02..4c6c431 100644
--- a/man/GFR_staging.Rd
+++ b/man/GFR_staging.Rd
@@ -2,14 +2,14 @@
% Please edit documentation in R/ckd.R
\name{GFR_staging}
\alias{GFR_staging}
-\alias{GFR_staging.default}
+\alias{GFR_staging.data.frame}
\alias{GFR_staging.units}
\alias{GFR_staging.numeric}
\title{GFR Staging}
\usage{
GFR_staging(...)
-\method{GFR_staging}{default}(.data, GFR, ...)
+\method{GFR_staging}{data.frame}(.data, GFR, ...)
\method{GFR_staging}{units}(GFR, ...)
@@ -21,14 +21,35 @@ GFR_staging(...)
\item{.data}{(data.frame) A data.frame, optional}
\item{GFR}{Glomerular filtration rate
-column name, or vector if \code{.data} not provided}
+column name, or vector of units or numeric if \code{.data} is not provided}
}
\value{
GFR category
}
\description{
-GFR Staging
+Using KDIGO 2012 Clinical Practice Guideline for
+the Evaluation and Management of Chronic Kidney Disease
+Volume 3 | Issue 1 | January 2013
+}
+\details{
+\itemize{
+\item{G1: Normal or high GFR, \eqn{\ge}90}
+\item{G2: Mildly decreased, 60-89}
+\item{G3a: Mildly to moderately decreased, 45-59}
+\item{G3b: Moderately to severely decreased, 30-44}
+\item{G4: Severely decreased, 15-29}
+\item{G5: Kidney failure, <15}
+}
+
+See \url{https://kdigo.org/guidelines/ckd-evaluation-and-management/} for more details
}
\examples{
-print("todo")
+df <- tibble::tibble(
+ eGFR = units::set_units(c(-1, NA, 100, 70, 50, 35, 20, 10), "mL/min/1.73m2")
+)
+
+GFR_staging(df, "eGFR")
+
+df \%>\%
+ dplyr::mutate(GFR_level = GFR_staging(eGFR))
}
diff --git a/man/aki.Rd b/man/aki.Rd
deleted file mode 100644
index be509e0..0000000
--- a/man/aki.Rd
+++ /dev/null
@@ -1,49 +0,0 @@
-% Generated by roxygen2: do not edit by hand
-% Please edit documentation in R/aki.R
-\name{aki}
-\alias{aki}
-\alias{aki.default}
-\alias{aki.units}
-\alias{aki.numeric}
-\title{Codify AKI from Serum Creatinine and/or Urine Output}
-\usage{
-aki(...)
-
-\method{aki}{default}(.data, SCr = NULL, bCr = NULL, UO = NULL, dttm = NULL, pt_id = NULL, ...)
-
-\method{aki}{units}(SCr = NULL, bCr = NULL, UO = NULL, dttm = NULL, pt_id = NULL, ...)
-
-\method{aki}{numeric}(SCr = NULL, bCr = NULL, UO = NULL, dttm = NULL, pt_id = NULL, ...)
-}
-\arguments{
-\item{...}{Further optional arguments}
-
-\item{.data}{(data.frame) A data.frame, optional}
-
-\item{SCr}{Serum creatinine
-column name, or vector if \code{.data} not provided}
-
-\item{bCr}{Baseline creatinine
-column name, or vector if \code{.data} not provided}
-
-\item{UO}{Urine output
-column name, or vector if \code{.data} not provided}
-
-\item{dttm}{DateTime
-column name, or vector if \code{.data} not provided}
-
-\item{pt_id}{Patient ID
-column name, or vector if \code{.data} not provided}
-}
-\description{
-Using KDIGO Clinical Practice Guideline for Acute Kidney Injury
-Volume 2 | Issue 1 | March 2012
-}
-\details{
-Provided a series of Serum Creatinine readings and/or Urine Output, aki()
-calculates whether or not a patient has AKI. The staging (1, 2, 3) of AKI is
-also calculated
-}
-\examples{
-print("todo")
-}
diff --git a/man/aki_SCr.Rd b/man/aki_SCr.Rd
index 2d60dcc..b36e82e 100644
--- a/man/aki_SCr.Rd
+++ b/man/aki_SCr.Rd
@@ -2,14 +2,14 @@
% Please edit documentation in R/aki.R
\name{aki_SCr}
\alias{aki_SCr}
-\alias{aki_SCr.default}
+\alias{aki_SCr.data.frame}
\alias{aki_SCr.units}
\alias{aki_SCr.numeric}
-\title{AKI Staging based on changes in creatinine}
+\title{AKI Staging based on Changes in Serum Creatinine}
\usage{
aki_SCr(...)
-\method{aki_SCr}{default}(.data, SCr, dttm, pt_id, ...)
+\method{aki_SCr}{data.frame}(.data, SCr, dttm, pt_id, ...)
\method{aki_SCr}{units}(SCr, dttm, pt_id, ...)
@@ -21,20 +21,34 @@ aki_SCr(...)
\item{.data}{(data.frame) A data.frame, optional}
\item{SCr}{Serum creatinine
-column name, or vector if \code{.data} not provided}
+column name, or vector of units or numeric if \code{.data} is not provided}
\item{dttm}{DateTime
-column name, or vector if \code{.data} not provided}
+column name, or vector of POSIXct if \code{.data} is not provided}
\item{pt_id}{Patient ID
-column name, or vector if \code{.data} not provided}
+column name, or vector of characters or factors if \code{.data} is not provided}
}
\value{
(ordered factor) AKI stages
}
\description{
-AKI Staging based on changes in creatinine
+Using KDIGO Clinical Practice Guideline for
+Acute Kidney Injury
+Volume 2 | Issue 1 | March 2012
+}
+\details{
+\itemize{
+\item{AKI Stage 1: \eqn{\ge}0.3 mg/dl (\eqn{\ge}26.5 mmol/l) increase}
+\item{AKI Stage 2: N/A}
+\item{AKI Stage 3: \eqn{\ge}4.0 mg/dl (\eqn{\ge}353.6 mmol/l)}
+}
+
+See \url{https://kdigo.org/guidelines/acute-kidney-injury/} for more details.
}
\examples{
-print("todo")
+aki_SCr(aki_pt_data, SCr = "SCr_", dttm = "dttm_", pt_id = "pt_id_")
+
+aki_pt_data \%>\%
+ dplyr::mutate(aki = aki_SCr(SCr = SCr_, dttm = dttm_, pt_id = pt_id_))
}
diff --git a/man/aki_UO.Rd b/man/aki_UO.Rd
index 7e401b9..20422cf 100644
--- a/man/aki_UO.Rd
+++ b/man/aki_UO.Rd
@@ -2,14 +2,14 @@
% Please edit documentation in R/aki.R
\name{aki_UO}
\alias{aki_UO}
-\alias{aki_UO.default}
+\alias{aki_UO.data.frame}
\alias{aki_UO.units}
\alias{aki_UO.numeric}
-\title{AKI Staging based on urine output}
+\title{AKI Staging based on Urine Output}
\usage{
aki_UO(...)
-\method{aki_UO}{default}(.data, UO, dttm, pt_id, ...)
+\method{aki_UO}{data.frame}(.data, UO, dttm, pt_id, ...)
\method{aki_UO}{units}(UO, dttm, pt_id, ...)
@@ -21,20 +21,34 @@ aki_UO(...)
\item{.data}{(data.frame) A data.frame, optional}
\item{UO}{Urine output
-column name, or vector if \code{.data} not provided}
+column name, or vector of units or numeric if \code{.data} is not provided}
\item{dttm}{DateTime
-column name, or vector if \code{.data} not provided}
+column name, or vector of POSIXct if \code{.data} is not provided}
\item{pt_id}{Patient ID
-column name, or vector if \code{.data} not provided}
+column name, or vector of characters or factors if \code{.data} is not provided}
}
\value{
(ordered factor) AKI stages
}
\description{
-AKI Staging based on urine output
+Using KDIGO Clinical Practice Guideline for
+Acute Kidney Injury
+Volume 2 | Issue 1 | March 2012
+}
+\details{
+\itemize{
+\item{AKI Stage 1: <0.5 ml/kg/h for 6–12 hours}
+\item{AKI Stage 2: <0.5 ml/kg/h for \eqn{\ge}12 hours}
+\item{AKI Stage 3: <0.3 ml/kg/h for \eqn{\ge}24 hours OR Anuria for \eqn{\ge}12 hours}
+}
+
+See \url{https://kdigo.org/guidelines/acute-kidney-injury/} for more details.
}
\examples{
-print("todo")
+aki_UO(aki_pt_data, UO = "UO_", dttm = "dttm_", pt_id = "pt_id_")
+
+aki_pt_data \%>\%
+ dplyr::mutate(aki = aki_UO(UO = UO_, dttm = dttm_, pt_id = pt_id_))
}
diff --git a/man/aki_bCr.Rd b/man/aki_bCr.Rd
index ff36691..be52bb4 100644
--- a/man/aki_bCr.Rd
+++ b/man/aki_bCr.Rd
@@ -2,14 +2,14 @@
% Please edit documentation in R/aki.R
\name{aki_bCr}
\alias{aki_bCr}
-\alias{aki_bCr.default}
+\alias{aki_bCr.data.frame}
\alias{aki_bCr.units}
\alias{aki_bCr.numeric}
-\title{AKI Staging based on baseline creatinine}
+\title{AKI Staging based on Baseline Serum Creatinine}
\usage{
aki_bCr(...)
-\method{aki_bCr}{default}(.data, SCr, bCr, ...)
+\method{aki_bCr}{data.frame}(.data, SCr, bCr, ...)
\method{aki_bCr}{units}(SCr, bCr, ...)
@@ -21,17 +21,31 @@ aki_bCr(...)
\item{.data}{(data.frame) A data.frame, optional}
\item{SCr}{Serum creatinine
-column name, or vector if \code{.data} not provided}
+column name, or vector of units or numeric if \code{.data} is not provided}
\item{bCr}{Baseline creatinine
-column name, or vector if \code{.data} not provided}
+column name, or vector of units or numeric if \code{.data} is not provided}
}
\value{
(ordered factor) AKI stages
}
\description{
-AKI Staging based on baseline creatinine
+Using KDIGO Clinical Practice Guideline for
+Acute Kidney Injury
+Volume 2 | Issue 1 | March 2012
+}
+\details{
+\itemize{
+\item{AKI Stage 1: 1.5-1.9 times baseline}
+\item{AKI Stage 2: 2.0-2.9 times baseline}
+\item{AKI Stage 3: 3.0 times baseline}
+}
+
+See \url{https://kdigo.org/guidelines/acute-kidney-injury/} for more details.
}
\examples{
-print("todo")
+aki_bCr(aki_pt_data, SCr = "SCr_", bCr = "bCr_")
+
+aki_pt_data \%>\%
+ dplyr::mutate(aki = aki_bCr(SCr = SCr_, bCr = bCr_))
}
diff --git a/man/aki_pt_data.Rd b/man/aki_pt_data.Rd
new file mode 100644
index 0000000..64efc76
--- /dev/null
+++ b/man/aki_pt_data.Rd
@@ -0,0 +1,19 @@
+% Generated by roxygen2: do not edit by hand
+% Please edit documentation in R/data-aki.R
+\docType{data}
+\name{aki_pt_data}
+\alias{aki_pt_data}
+\title{AKI Patient Data}
+\format{
+An object of class \code{tbl_df} (inherits from \code{tbl}, \code{data.frame}) with 27 rows and 7 columns.
+}
+\usage{
+aki_pt_data
+}
+\description{
+A sample dataset to demonstrate calculating AKI with \code{epocakir}
+}
+\examples{
+aki_pt_data
+}
+\keyword{datasets}
diff --git a/man/aki_stages.Rd b/man/aki_stages.Rd
new file mode 100644
index 0000000..c4a929c
--- /dev/null
+++ b/man/aki_stages.Rd
@@ -0,0 +1,22 @@
+% Generated by roxygen2: do not edit by hand
+% Please edit documentation in R/aki.R
+\docType{data}
+\name{aki_stages}
+\alias{aki_stages}
+\title{AKI Stages}
+\format{
+An object of class \code{ordered} (inherits from \code{factor}) of length 4.
+}
+\usage{
+aki_stages
+}
+\description{
+Ordered factor of AKI stages
+}
+\details{
+See \url{https://kdigo.org/guidelines/ckd-evaluation-and-management/} for more details
+}
+\examples{
+aki_stages
+}
+\keyword{datasets}
diff --git a/man/aki_staging.Rd b/man/aki_staging.Rd
new file mode 100644
index 0000000..ca68489
--- /dev/null
+++ b/man/aki_staging.Rd
@@ -0,0 +1,74 @@
+% Generated by roxygen2: do not edit by hand
+% Please edit documentation in R/aki.R
+\name{aki_staging}
+\alias{aki_staging}
+\alias{aki_staging.data.frame}
+\alias{aki_staging.units}
+\alias{aki_staging.numeric}
+\title{Codify AKI from Serum Creatinine and/or Urine Output}
+\usage{
+aki_staging(...)
+
+\method{aki_staging}{data.frame}(
+ .data,
+ SCr = NULL,
+ bCr = NULL,
+ UO = NULL,
+ dttm = NULL,
+ pt_id = NULL,
+ ...
+)
+
+\method{aki_staging}{units}(SCr = NULL, bCr = NULL, UO = NULL, dttm = NULL, pt_id = NULL, ...)
+
+\method{aki_staging}{numeric}(SCr = NULL, bCr = NULL, UO = NULL, dttm = NULL, pt_id = NULL, ...)
+}
+\arguments{
+\item{...}{Further optional arguments}
+
+\item{.data}{(data.frame) A data.frame, optional}
+
+\item{SCr}{Serum creatinine
+column name, or vector of units or numeric if \code{.data} is not provided}
+
+\item{bCr}{Baseline creatinine
+column name, or vector of units or numeric if \code{.data} is not provided}
+
+\item{UO}{Urine output
+column name, or vector of units or numeric if \code{.data} is not provided}
+
+\item{dttm}{DateTime
+column name, or vector of POSIXct if \code{.data} is not provided}
+
+\item{pt_id}{Patient ID
+column name, or vector of characters or factors if \code{.data} is not provided}
+}
+\description{
+Using KDIGO Clinical Practice Guideline for
+Acute Kidney Injury
+Volume 2 | Issue 1 | March 2012
+}
+\details{
+Provided a baseline creatinine, series of Serum Creatinine readings and/or
+Urine Output, \code{aki_staging()} calculates whether or not a patient has AKI.
+The staging (1, 2, 3) of AKI is returned.
+
+When multiple columns are provided, \code{aki_staging()} will automatically
+calculate whether or not AKI has occurred using each KDIGIO definition.
+
+\itemize{
+\item{\code{\link[=aki_bCr]{aki_bCr()}}: Staging of AKI based on baseline serum creatinine}
+\item{\code{\link[=aki_SCr]{aki_SCr()}}: Staging of AKI based on changes in serum creatinine}
+\item{\code{\link[=aki_UO]{aki_UO()}}: Staging of AKI based on urine output}
+}
+
+The most severe AKI stage is then returned.
+
+See \url{https://kdigo.org/guidelines/acute-kidney-injury/} for more details.
+}
+\examples{
+aki_staging(aki_pt_data, SCr = "SCr_", bCr = "bCr_", UO = "UO_", dttm = "dttm_", pt_id = "pt_id_")
+
+aki_pt_data \%>\%
+ dplyr::mutate(aki = aki_staging(SCr = SCr_, bCr = bCr_, UO = UO_, dttm = dttm_, pt_id = pt_id_))
+}
diff --git a/man/anemia.Rd b/man/anemia.Rd
index 3bb3dad..e0b3075 100644
--- a/man/anemia.Rd
+++ b/man/anemia.Rd
@@ -2,14 +2,14 @@
% Please edit documentation in R/anemia.R
\name{anemia}
\alias{anemia}
-\alias{anemia.default}
+\alias{anemia.data.frame}
\alias{anemia.units}
\alias{anemia.numeric}
\title{Diagnosis of anemia from Hb concentration}
\usage{
anemia(...)
-\method{anemia}{default}(.data, Hb, age, male, ...)
+\method{anemia}{data.frame}(.data, Hb, age, male, ...)
\method{anemia}{units}(Hb, age, male, ...)
@@ -21,21 +21,39 @@ anemia(...)
\item{.data}{(data.frame) A data.frame, optional}
\item{Hb}{Hemoglobin concenration
-column name, or vector if \code{.data} not provided}
+column name, or vector of units or numeric if \code{.data} is not provided}
\item{age}{Age of patient
-column name, or vector if \code{.data} not provided}
+column name, or vector of units or numeric if \code{.data} is not provided}
\item{male}{Male or not
-column name, or vector if \code{.data} not provided}
+column name, or vector of logical (TRUE/FALSE) if \code{.data} is not provided}
}
\value{
Anemia
as logical \code{TRUE} or \code{FALSE}
}
\description{
-Diagnosis of anemia from Hb concentration
+KDIGO Clinical Practice Guideline for
+Anemia in Chronic Kidney Disease
+Volume 2 | Issue 4 | August (2) 2012
+}
+\details{
+\itemize{
+\item{Adults and children >15 years with CKD when the Hb concentration is
+<13.0 g/dl (<130 g/l) in males and
+<12.0 g/dl (<120 g/l) in females.}
+\item{Children with CKD if Hb concentration is
+<11.0 g/dl (<110 g/l) in children 0.5-5 years,
+<11.5 g/dl (115 g/l) in children 5-12 years,
+and <12.0 g/dl (120 g/l) in children 12-15 years.}
+}
+
+See \url{https://kdigo.org/guidelines/anemia-in-ckd/} for more details.
}
\examples{
-print("todo")
+anemia(anemia_pt_data, Hb = "Hb", age = "age", male = "male")
+
+anemia_pt_data \%>\%
+ dplyr::mutate(anemia = anemia(Hb = Hb, age = age, male = male))
}
diff --git a/man/anemia_pt_data.Rd b/man/anemia_pt_data.Rd
new file mode 100644
index 0000000..b680e6f
--- /dev/null
+++ b/man/anemia_pt_data.Rd
@@ -0,0 +1,19 @@
+% Generated by roxygen2: do not edit by hand
+% Please edit documentation in R/data-anemia.R
+\docType{data}
+\name{anemia_pt_data}
+\alias{anemia_pt_data}
+\title{Anemia Patient Data}
+\format{
+An object of class \code{tbl_df} (inherits from \code{tbl}, \code{data.frame}) with 10 rows and 3 columns.
+}
+\usage{
+anemia_pt_data
+}
+\description{
+A sample dataset to demonstrate calculating anemia with \code{epocakir}
+}
+\examples{
+anemia_pt_data
+}
+\keyword{datasets}
diff --git a/man/combine_date_time_cols.Rd b/man/combine_date_time_cols.Rd
index 5c70cb9..dac80f6 100644
--- a/man/combine_date_time_cols.Rd
+++ b/man/combine_date_time_cols.Rd
@@ -19,5 +19,12 @@ object x)}
Combine date and time columns into a single DateTime column
}
\examples{
-print("todo")
+df <- data.frame(
+ date_a = as.Date(c("2020-01-01", "2020-01-02")),
+ date_b = as.POSIXct(c("2020-02-01", "2020-02-02")),
+ time_a = as.POSIXct(c("1900-01-01 01:01:01", "1900-01-01 02:02:02")),
+ time_b = as.POSIXct(c("1900-01-01 01:01:01", "1900-01-01 02:02:02"))
+)
+
+combine_date_time_cols(df)
}
diff --git a/man/combn_changes.Rd b/man/combn_changes.Rd
index a794e48..f4d2c7e 100644
--- a/man/combn_changes.Rd
+++ b/man/combn_changes.Rd
@@ -2,13 +2,13 @@
% Please edit documentation in R/utils.R
\name{combn_changes}
\alias{combn_changes}
-\alias{combn_changes.default}
+\alias{combn_changes.data.frame}
\alias{combn_changes.POSIXct}
\title{Combinatorics changes}
\usage{
combn_changes(...)
-\method{combn_changes}{default}(.data, dttm, val, pt_id, ...)
+\method{combn_changes}{data.frame}(.data, dttm, val, pt_id, ...)
\method{combn_changes}{POSIXct}(dttm, val, pt_id, ...)
}
@@ -18,21 +18,24 @@ combn_changes(...)
\item{.data}{(data.frame) A data.frame, optional}
\item{dttm}{DateTime
-column name, or vector if \code{.data} not provided}
+column name, or vector of POSIXct if \code{.data} is not provided}
\item{val}{Variable
-column name, or vector if \code{.data} not provided}
+column name, or vector of units or numeric if \code{.data} is not provided}
\item{pt_id}{Patient ID
-column name, or vector if \code{.data} not provided}
+column name, or vector of characters or factors if \code{.data} is not provided}
}
\value{
Combinatorics changes
of the same type provided (numeric or units)
}
\description{
-Compares a value with previous values
+Compares a value with all previous values
}
\examples{
-print("todo")
+combn_changes(aki_pt_data, dttm = "dttm_", val = "SCr_", pt_id = "pt_id_")
+
+aki_pt_data \%>\%
+ combn_changes(dttm_, SCr_, pt_id_)
}
diff --git a/man/eGFR.Rd b/man/eGFR.Rd
index 3b69cff..cfff15b 100644
--- a/man/eGFR.Rd
+++ b/man/eGFR.Rd
@@ -2,14 +2,14 @@
% Please edit documentation in R/ckd.R
\name{eGFR}
\alias{eGFR}
-\alias{eGFR.default}
+\alias{eGFR.data.frame}
\alias{eGFR.units}
\alias{eGFR.numeric}
\title{GFR Estimation}
\usage{
eGFR(...)
-\method{eGFR}{default}(
+\method{eGFR}{data.frame}(
.data,
SCr = NULL,
SCysC = NULL,
@@ -52,46 +52,64 @@ eGFR(...)
\item{.data}{(data.frame) A data.frame, optional}
\item{SCr}{Serum creatinine
-column name, or vector if \code{.data} not provided}
+column name, or vector of units or numeric if \code{.data} is not provided}
\item{SCysC}{Serum Cystatin C
-column name, or vector if \code{.data} not provided}
+column name, or vector of units or numeric if \code{.data} is not provided}
\item{Age}{Age of patient
-column name, or vector if \code{.data} not provided}
+column name, or vector of units or numeric if \code{.data} is not provided}
\item{height}{Height of patient
-column name, or vector if \code{.data} not provided}
+column name, or vector of units or numeric if \code{.data} is not provided}
\item{BUN}{Blood urea nitrogen
-column name, or vector if \code{.data} not provided}
+column name, or vector of units or numeric if \code{.data} is not provided}
\item{male}{Male or not
-column name, or vector if \code{.data} not provided}
+column name, or vector of logical (TRUE/FALSE) if \code{.data} is not provided}
\item{black}{Black race or not
-column name, or vector if \code{.data} not provided}
+column name, or vector of logical (TRUE/FALSE) if \code{.data} is not provided}
\item{pediatric}{(logical) Paediatric or not
-column name, or vector if \code{.data} not provided}
+column name, or vector of logical (TRUE/FALSE) if \code{.data} is not provided}
}
\value{
(units) Estimated glomerular filtration rate (eGFR)
of the same type provided (numeric or units in ml/min/1.73m2)
}
\description{
-\itemize{
-\item 2009 CKD-EPI creatinine equation
-\item 2012 CKD-EPI cystatin C equation
-\item 2012 CKD-EPI creatinine-cystatin C equation
-\item Pediatric equations
-}
+Using KDIGO 2012 Clinical Practice Guideline for
+the Evaluation and Management of Chronic Kidney Disease
+Volume 3 | Issue 1 | January 2013
}
\details{
+Automatic selection of equation to estimation the
+Glomerular Filtration Rate (eGFR), based on input data
+
\itemize{
-\item Automatic selection of the best equation to use
+\item{\code{\link[=eGFR_adult_SCr]{eGFR_adult_SCr()}}: 2009 CKD-EPI creatinine equation}
+\item{\code{\link[=eGFR_adult_SCysC]{eGFR_adult_SCysC()}}: 2012 CKD-EPI cystatin C equation}
+\item{\code{\link[=eGFR_adult_SCr_SCysC]{eGFR_adult_SCr_SCysC()}}: 2012 CKD-EPI creatinine-cystatin C equation}
+\item{\code{\link[=eGFR_child_SCr]{eGFR_child_SCr()}}: Pediatric creatinine-based equation}
+\item{\code{\link[=eGFR_child_SCr_BUN]{eGFR_child_SCr_BUN()}}: Pediatric creatinine-BUN equation}
+\item{\code{\link[=eGFR_child_SCysC]{eGFR_child_SCysC()}}: Pediatric cystatin C-based equation}
}
+
+See \url{https://kdigo.org/guidelines/ckd-evaluation-and-management/} for more details
}
\examples{
-print("todo")
+eGFR(eGFR_pt_data,
+ SCr = "SCr_", SCysC = "SCysC_",
+ Age = "Age_", height = "height_", BUN = "BUN_",
+ male = "male_", black = "black_", pediatric = "pediatric_"
+)
+
+eGFR_pt_data \%>\%
+ dplyr::mutate(eGFR = eGFR(
+ SCr = SCr_, SCysC = SCysC_,
+ Age = Age_, height = height_, BUN = BUN_,
+ male = male_, black = black_, pediatric = pediatric_
+ ))
}
diff --git a/man/eGFR_adult_SCr.Rd b/man/eGFR_adult_SCr.Rd
index 42d4a6b..0fd056c 100644
--- a/man/eGFR_adult_SCr.Rd
+++ b/man/eGFR_adult_SCr.Rd
@@ -2,14 +2,14 @@
% Please edit documentation in R/ckd.R
\name{eGFR_adult_SCr}
\alias{eGFR_adult_SCr}
-\alias{eGFR_adult_SCr.default}
+\alias{eGFR_adult_SCr.data.frame}
\alias{eGFR_adult_SCr.units}
\alias{eGFR_adult_SCr.numeric}
-\title{2009 CKD-EPI creatinine equation}
+\title{eGFR 2009 CKD-EPI creatinine equation}
\usage{
eGFR_adult_SCr(...)
-\method{eGFR_adult_SCr}{default}(.data, SCr, Age, male, black, ...)
+\method{eGFR_adult_SCr}{data.frame}(.data, SCr, Age, male, black, ...)
\method{eGFR_adult_SCr}{units}(SCr, Age, male, black, ...)
@@ -21,24 +21,36 @@ eGFR_adult_SCr(...)
\item{.data}{(data.frame) A data.frame, optional}
\item{SCr}{Serum creatinine
-column name, or vector if \code{.data} not provided}
+column name, or vector of units or numeric if \code{.data} is not provided}
\item{Age}{Age of patient
-column name, or vector if \code{.data} not provided}
+column name, or vector of units or numeric if \code{.data} is not provided}
\item{male}{Male or not
-column name, or vector if \code{.data} not provided}
+column name, or vector of logical (TRUE/FALSE) if \code{.data} is not provided}
\item{black}{Black race or not
-column name, or vector if \code{.data} not provided}
+column name, or vector of logical (TRUE/FALSE) if \code{.data} is not provided}
}
\value{
Estimated GFR
of the same type provided (numeric or units)
}
\description{
-2009 CKD-EPI creatinine equation
+Using KDIGO 2012 Clinical Practice Guideline for
+the Evaluation and Management of Chronic Kidney Disease
+Volume 3 | Issue 1 | January 2013
+}
+\details{
+See \url{https://kdigo.org/guidelines/ckd-evaluation-and-management/} for more details
}
\examples{
-print("todo")
+eGFR_adult_SCr(eGFR_pt_data,
+ SCr = "SCr_", Age = "Age_", male = "male_", black = "black_"
+)
+
+eGFR_pt_data \%>\%
+ dplyr::mutate(eGFR = eGFR_adult_SCr(
+ SCr = SCr_, Age = Age_, male = male_, black = black_
+ ))
}
diff --git a/man/eGFR_adult_SCr_SCysC.Rd b/man/eGFR_adult_SCr_SCysC.Rd
index c2b5b35..09fefde 100644
--- a/man/eGFR_adult_SCr_SCysC.Rd
+++ b/man/eGFR_adult_SCr_SCysC.Rd
@@ -2,14 +2,14 @@
% Please edit documentation in R/ckd.R
\name{eGFR_adult_SCr_SCysC}
\alias{eGFR_adult_SCr_SCysC}
-\alias{eGFR_adult_SCr_SCysC.default}
+\alias{eGFR_adult_SCr_SCysC.data.frame}
\alias{eGFR_adult_SCr_SCysC.units}
\alias{eGFR_adult_SCr_SCysC.numeric}
-\title{2012 CKD-EPI creatinine-cystatin C equation}
+\title{eGFR 2012 CKD-EPI creatinine-cystatin C equation}
\usage{
eGFR_adult_SCr_SCysC(...)
-\method{eGFR_adult_SCr_SCysC}{default}(.data, SCr, SCysC, Age, male, black, ...)
+\method{eGFR_adult_SCr_SCysC}{data.frame}(.data, SCr, SCysC, Age, male, black, ...)
\method{eGFR_adult_SCr_SCysC}{units}(SCr, SCysC, Age, male, black, ...)
@@ -21,27 +21,41 @@ eGFR_adult_SCr_SCysC(...)
\item{.data}{(data.frame) A data.frame, optional}
\item{SCr}{Serum creatinine
-column name, or vector if \code{.data} not provided}
+column name, or vector of units or numeric if \code{.data} is not provided}
\item{SCysC}{Serum Cystatin C
-column name, or vector if \code{.data} not provided}
+column name, or vector of units or numeric if \code{.data} is not provided}
\item{Age}{Age of patient
-column name, or vector if \code{.data} not provided}
+column name, or vector of units or numeric if \code{.data} is not provided}
\item{male}{Male or not
-column name, or vector if \code{.data} not provided}
+column name, or vector of logical (TRUE/FALSE) if \code{.data} is not provided}
\item{black}{Black race or not
-column name, or vector if \code{.data} not provided}
+column name, or vector of logical (TRUE/FALSE) if \code{.data} is not provided}
}
\value{
Estimated GFR
of the same type provided (numeric or units)
}
\description{
-2012 CKD-EPI creatinine-cystatin C equation
+Using KDIGO 2012 Clinical Practice Guideline for
+the Evaluation and Management of Chronic Kidney Disease
+Volume 3 | Issue 1 | January 2013
+}
+\details{
+See \url{https://kdigo.org/guidelines/ckd-evaluation-and-management/} for more details
}
\examples{
-print("todo")
+eGFR_adult_SCr_SCysC(eGFR_pt_data,
+ SCr = "SCr_", SCysC = "SCysC_",
+ Age = "Age_", male = "male_", black = "black_"
+)
+
+eGFR_pt_data \%>\%
+ dplyr::mutate(eGFR = eGFR_adult_SCr_SCysC(
+ SCr = SCr_, SCysC = SCysC_,
+ Age = Age_, male = male_, black = black_
+ ))
}
diff --git a/man/eGFR_adult_SCysC.Rd b/man/eGFR_adult_SCysC.Rd
index 0bb7d96..ee97aa3 100644
--- a/man/eGFR_adult_SCysC.Rd
+++ b/man/eGFR_adult_SCysC.Rd
@@ -2,14 +2,14 @@
% Please edit documentation in R/ckd.R
\name{eGFR_adult_SCysC}
\alias{eGFR_adult_SCysC}
-\alias{eGFR_adult_SCysC.default}
+\alias{eGFR_adult_SCysC.data.frame}
\alias{eGFR_adult_SCysC.units}
\alias{eGFR_adult_SCysC.numeric}
-\title{2012 CKD-EPI cystatin C equation}
+\title{eGFR 2012 CKD-EPI cystatin C equation}
\usage{
eGFR_adult_SCysC(...)
-\method{eGFR_adult_SCysC}{default}(.data, SCysC, Age, male, ...)
+\method{eGFR_adult_SCysC}{data.frame}(.data, SCysC, Age, male, ...)
\method{eGFR_adult_SCysC}{units}(SCysC, Age, male, ...)
@@ -21,21 +21,33 @@ eGFR_adult_SCysC(...)
\item{.data}{(data.frame) A data.frame, optional}
\item{SCysC}{Serum Cystatin C
-column name, or vector if \code{.data} not provided}
+column name, or vector of units or numeric if \code{.data} is not provided}
\item{Age}{Age of patient
-column name, or vector if \code{.data} not provided}
+column name, or vector of units or numeric if \code{.data} is not provided}
\item{male}{Male or not
-column name, or vector if \code{.data} not provided}
+column name, or vector of logical (TRUE/FALSE) if \code{.data} is not provided}
}
\value{
Estimated GFR
of the same type provided (numeric or units)
}
\description{
-2012 CKD-EPI cystatin C equation
+Using KDIGO 2012 Clinical Practice Guideline for
+the Evaluation and Management of Chronic Kidney Disease
+Volume 3 | Issue 1 | January 2013
+}
+\details{
+See \url{https://kdigo.org/guidelines/ckd-evaluation-and-management/} for more details
}
\examples{
-print("todo")
+eGFR_adult_SCysC(eGFR_pt_data,
+ SCysC = "SCysC_", Age = "Age_", male = "male_"
+)
+
+eGFR_pt_data \%>\%
+ dplyr::mutate(eGFR = eGFR_adult_SCysC(
+ SCysC = SCysC_, Age = Age_, male = male_
+ ))
}
diff --git a/man/eGFR_child_SCr.Rd b/man/eGFR_child_SCr.Rd
index 07a213c..1fb638b 100644
--- a/man/eGFR_child_SCr.Rd
+++ b/man/eGFR_child_SCr.Rd
@@ -2,14 +2,14 @@
% Please edit documentation in R/ckd.R
\name{eGFR_child_SCr}
\alias{eGFR_child_SCr}
-\alias{eGFR_child_SCr.default}
+\alias{eGFR_child_SCr.data.frame}
\alias{eGFR_child_SCr.units}
\alias{eGFR_child_SCr.numeric}
-\title{Pediatric SCr and Height}
+\title{eGFR Pediatric SCr and Height}
\usage{
eGFR_child_SCr(...)
-\method{eGFR_child_SCr}{default}(.data, SCr, height, ...)
+\method{eGFR_child_SCr}{data.frame}(.data, SCr, height, ...)
\method{eGFR_child_SCr}{units}(SCr, height, ...)
@@ -21,18 +21,30 @@ eGFR_child_SCr(...)
\item{.data}{(data.frame) A data.frame, optional}
\item{SCr}{Serum creatinine
-column name, or vector if \code{.data} not provided}
+column name, or vector of units or numeric if \code{.data} is not provided}
\item{height}{Height of patient
-column name, or vector if \code{.data} not provided}
+column name, or vector of units or numeric if \code{.data} is not provided}
}
\value{
Estimated GFR
of the same type provided (numeric or units)
}
\description{
-Pediatric SCr and Height
+Using KDIGO 2012 Clinical Practice Guideline for
+the Evaluation and Management of Chronic Kidney Disease
+Volume 3 | Issue 1 | January 2013
+}
+\details{
+See \url{https://kdigo.org/guidelines/ckd-evaluation-and-management/} for more details
}
\examples{
-print("todo")
+eGFR_child_SCr(eGFR_pt_data,
+ SCr = "SCr_", height = "height_"
+)
+
+eGFR_pt_data \%>\%
+ dplyr::mutate(eGFR = eGFR_child_SCr(
+ SCr = SCr_, height = height_,
+ ))
}
diff --git a/man/eGFR_child_SCr_BUN.Rd b/man/eGFR_child_SCr_BUN.Rd
index 67c64f5..81e6222 100644
--- a/man/eGFR_child_SCr_BUN.Rd
+++ b/man/eGFR_child_SCr_BUN.Rd
@@ -2,14 +2,14 @@
% Please edit documentation in R/ckd.R
\name{eGFR_child_SCr_BUN}
\alias{eGFR_child_SCr_BUN}
-\alias{eGFR_child_SCr_BUN.default}
+\alias{eGFR_child_SCr_BUN.data.frame}
\alias{eGFR_child_SCr_BUN.units}
\alias{eGFR_child_SCr_BUN.numeric}
-\title{Pediatric SCr, Height and BUN}
+\title{eGFR Pediatric SCr, Height and BUN}
\usage{
eGFR_child_SCr_BUN(...)
-\method{eGFR_child_SCr_BUN}{default}(.data, SCr, height, BUN, ...)
+\method{eGFR_child_SCr_BUN}{data.frame}(.data, SCr, height, BUN, ...)
\method{eGFR_child_SCr_BUN}{units}(SCr, height, BUN, ...)
@@ -21,21 +21,33 @@ eGFR_child_SCr_BUN(...)
\item{.data}{(data.frame) A data.frame, optional}
\item{SCr}{Serum creatinine
-column name, or vector if \code{.data} not provided}
+column name, or vector of units or numeric if \code{.data} is not provided}
\item{height}{Height of patient
-column name, or vector if \code{.data} not provided}
+column name, or vector of units or numeric if \code{.data} is not provided}
\item{BUN}{Blood urea nitrogen
-column name, or vector if \code{.data} not provided}
+column name, or vector of units or numeric if \code{.data} is not provided}
}
\value{
Estimated GFR
of the same type provided (numeric or units)
}
\description{
-Pediatric SCr, Height and BUN
+Using KDIGO 2012 Clinical Practice Guideline for
+the Evaluation and Management of Chronic Kidney Disease
+Volume 3 | Issue 1 | January 2013
+}
+\details{
+See \url{https://kdigo.org/guidelines/ckd-evaluation-and-management/} for more details
}
\examples{
-print("todo")
+eGFR_child_SCr_BUN(eGFR_pt_data,
+ SCr = "SCr_", height = "height_", BUN = "BUN_",
+)
+
+eGFR_pt_data \%>\%
+ dplyr::mutate(eGFR = eGFR_child_SCr_BUN(
+ SCr = SCr_, height = height_, BUN = BUN_,
+ ))
}
diff --git a/man/eGFR_child_SCysC.Rd b/man/eGFR_child_SCysC.Rd
index 9dd77bc..92741be 100644
--- a/man/eGFR_child_SCysC.Rd
+++ b/man/eGFR_child_SCysC.Rd
@@ -2,14 +2,14 @@
% Please edit documentation in R/ckd.R
\name{eGFR_child_SCysC}
\alias{eGFR_child_SCysC}
-\alias{eGFR_child_SCysC.default}
+\alias{eGFR_child_SCysC.data.frame}
\alias{eGFR_child_SCysC.units}
\alias{eGFR_child_SCysC.numeric}
-\title{Pediatric SCysC}
+\title{eGFR Pediatric SCysC}
\usage{
eGFR_child_SCysC(...)
-\method{eGFR_child_SCysC}{default}(.data, SCysC, ...)
+\method{eGFR_child_SCysC}{data.frame}(.data, SCysC, ...)
\method{eGFR_child_SCysC}{units}(SCysC, ...)
@@ -21,15 +21,27 @@ eGFR_child_SCysC(...)
\item{.data}{(data.frame) A data.frame, optional}
\item{SCysC}{Serum Cystatin C
-column name, or vector if \code{.data} not provided}
+column name, or vector of units or numeric if \code{.data} is not provided}
}
\value{
Estimated GFR
of the same type provided (numeric or units)
}
\description{
-Pediatric SCysC
+Using KDIGO 2012 Clinical Practice Guideline for
+the Evaluation and Management of Chronic Kidney Disease
+Volume 3 | Issue 1 | January 2013
+}
+\details{
+See \url{https://kdigo.org/guidelines/ckd-evaluation-and-management/} for more details
}
\examples{
-print("todo")
+eGFR_child_SCysC(eGFR_pt_data,
+ SCysC = "SCysC_"
+)
+
+eGFR_pt_data \%>\%
+ dplyr::mutate(eGFR = eGFR_child_SCysC(
+ SCysC = SCysC_
+ ))
}
diff --git a/man/eGFR_pt_data.Rd b/man/eGFR_pt_data.Rd
new file mode 100644
index 0000000..17a669d
--- /dev/null
+++ b/man/eGFR_pt_data.Rd
@@ -0,0 +1,19 @@
+% Generated by roxygen2: do not edit by hand
+% Please edit documentation in R/data-eGFR.R
+\docType{data}
+\name{eGFR_pt_data}
+\alias{eGFR_pt_data}
+\title{eGFR Patient Data}
+\format{
+An object of class \code{tbl_df} (inherits from \code{tbl}, \code{data.frame}) with 51 rows and 10 columns.
+}
+\usage{
+eGFR_pt_data
+}
+\description{
+A sample dataset to demonstrate calculating eGFR with \code{epocakir}
+}
+\examples{
+eGFR_pt_data
+}
+\keyword{datasets}
diff --git a/tests/testthat/test-aki.R b/tests/testthat/test-aki.R
index 2fdffee..30e92d0 100644
--- a/tests/testthat/test-aki.R
+++ b/tests/testthat/test-aki.R
@@ -1,4 +1,4 @@
-# consider using Table 7 as the test cases
+# consider adding KDIGO Table 7 as the test cases
aki_bCr_test_df <- function(env = parent.frame()) {
tibble::tibble(
@@ -100,25 +100,25 @@ aki_test_df <- function(env = parent.frame()) {
}
-test_that("aki() on full aki_test_df()", {
+test_that("aki_staging() on full aki_test_df()", {
ep <- aki_test_df()$aki_
- df_str <- aki(aki_test_df(),
+ df_str <- aki_staging(aki_test_df(),
SCr = "SCr_", bCr = "bCr_", UO = "UO_", dttm = "dttm_", pt_id = "pt_id_"
)
df_mut <- aki_test_df() %>%
- dplyr::mutate(aki = aki(
+ dplyr::mutate(aki = aki_staging(
SCr = SCr_, bCr = bCr_, UO = UO_, dttm = dttm_, pt_id = pt_id_
)) %>%
dplyr::pull(aki)
- df_uvec <- aki(
+ df_uvec <- aki_staging(
aki_test_df()$SCr_,
aki_test_df()$bCr_,
aki_test_df()$UO_,
aki_test_df()$dttm_,
aki_test_df()$pt_id_
)
- df_nvec <- aki(
+ df_nvec <- aki_staging(
as.numeric(aki_test_df()$SCr_),
as.numeric(aki_test_df()$bCr_),
as.numeric(aki_test_df()$UO_),
@@ -132,30 +132,30 @@ test_that("aki() on full aki_test_df()", {
expect_identical(df_nvec, ep)
})
-test_that("aki() on individual data.frames", {
+test_that("aki_staging() on individual data.frames", {
expect_identical(
- aki(aki_bCr_test_df(), SCr = "SCr_", bCr = "bCr_"),
+ aki_staging(aki_bCr_test_df(), SCr = "SCr_", bCr = "bCr_"),
aki_bCr_test_df()$aki_bCr
)
expect_identical(
- aki(aki_SCr_test_rand_df(), SCr = "SCr_", dttm = "dttm_", pt_id = "pt_id_"),
+ aki_staging(aki_SCr_test_rand_df(), SCr = "SCr_", dttm = "dttm_", pt_id = "pt_id_"),
aki_SCr_test_rand_df()$aki_SCr
)
expect_identical(
- aki(aki_UO_test_rand_df(), UO = "UO_", dttm = "dttm_", pt_id = "pt_id_"),
+ aki_staging(aki_UO_test_rand_df(), UO = "UO_", dttm = "dttm_", pt_id = "pt_id_"),
aki_UO_test_rand_df()$aki_UO
)
})
-test_that("aki() warnings", {
+test_that("aki_staging() warnings", {
df_no_pt_id <- aki_SCr_test_raw_df() %>%
dplyr::filter(pt_id_ == "pt1")
expect_warning(
- aki(df_no_pt_id, SCr = "SCr_", dttm = "dttm_"),
+ aki_staging(df_no_pt_id, SCr = "SCr_", dttm = "dttm_"),
".*Assuming provided data is for a single patient"
)
expect_identical(
- suppressWarnings(aki(df_no_pt_id, SCr = "SCr_", dttm = "dttm_")),
+ suppressWarnings(aki_staging(df_no_pt_id, SCr = "SCr_", dttm = "dttm_")),
df_no_pt_id$aki_SCr
)
})
diff --git a/tests/testthat/test-anemia.R b/tests/testthat/test-anemia.R
index b630e92..d7d9e89 100644
--- a/tests/testthat/test-anemia.R
+++ b/tests/testthat/test-anemia.R
@@ -31,7 +31,7 @@ test_that("anemia() for data.frame", {
anemia(anemia_df(), Hb, age, male),
anemia_ep()
)
- expect_identical( # TODO add this to all cases
+ expect_identical(
anemia_df() %>% anemia(Hb, age, male),
anemia_ep()
)
diff --git a/tests/testthat/test-ckd.R b/tests/testthat/test-ckd.R
index 6d16466..c01e741 100644
--- a/tests/testthat/test-ckd.R
+++ b/tests/testthat/test-ckd.R
@@ -128,11 +128,6 @@ test_that("eGFR() on full eGFR_df()", {
Age = "Age_", height = "height_", BUN = "BUN_",
male = "male_", black = "black_", pediatric = "pediatric_"
)
- # df_sym <- eGFR(eGFR_df(),
- # SCr = SCr_, SCysC = SCysC_,
- # Age = Age_, height = height_, BUN = BUN_,
- # male = male_, black = black_, pediatric = pediatric_
- # )
df_mut <- eGFR_df() %>%
dplyr::mutate(eGFR = eGFR(
SCr = SCr_, SCysC = SCysC_,
@@ -162,7 +157,6 @@ test_that("eGFR() on full eGFR_df()", {
)
lapply(abs(df_str - ep), expect_lte, eGFR_tol())
- # lapply(abs(df_sym - ep), expect_lte, eGFR_tol())
lapply(abs(df_mut - ep), expect_lte, eGFR_tol())
lapply(abs(df_uvec - ep), expect_lte, eGFR_tol())
lapply(abs(df_nvec - as.numeric(ep)), expect_lte, as.numeric(eGFR_tol()))
diff --git a/tests/testthat/test-utils.R b/tests/testthat/test-utils.R
index 3538d00..16d4512 100644
--- a/tests/testthat/test-utils.R
+++ b/tests/testthat/test-utils.R
@@ -289,4 +289,9 @@ test_that("combn_changes for POSIXct", {
expect_equal(df, changes_exp_df())
})
-# Add error test case where only 1 row for a pt_id
+test_that("combn_changes with n < m", {
+ df <- changes_raw_df()[1:7, ]
+ ep <- changes_exp_df()[1:5, ]
+ ep$D.dttm_ <- as.difftime(as.numeric(ep$D.dttm_, units = "days"), units = "days")
+ expect_equal(combn_changes(df, "dttm_", "SCr_", "pt_id_"), ep)
+})