From 3057680c5aec8317a3adc4c1cff84cc074789c4e Mon Sep 17 00:00:00 2001 From: alwinw <16846521+alwinw@users.noreply.github.com> Date: Sat, 5 Jun 2021 14:56:21 +1000 Subject: [PATCH 01/18] Added data-raw data generators --- data-raw/aki-data.R | 103 +++++++++++++++++++++++++++++++++++++ data-raw/ckd-data.R | 122 ++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 225 insertions(+) create mode 100644 data-raw/aki-data.R create mode 100644 data-raw/ckd-data.R diff --git a/data-raw/aki-data.R b/data-raw/aki-data.R new file mode 100644 index 0000000..1a3a002 --- /dev/null +++ b/data-raw/aki-data.R @@ -0,0 +1,103 @@ +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/ckd-data.R b/data-raw/ckd-data.R new file mode 100644 index 0000000..818ae6d --- /dev/null +++ b/data-raw/ckd-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) From 0b8ad742aaa3507c907e35b06c8464034ce15f3e Mon Sep 17 00:00:00 2001 From: alwinw <16846521+alwinw@users.noreply.github.com> Date: Sat, 5 Jun 2021 15:00:50 +1000 Subject: [PATCH 02/18] Generated pt_data .rda files --- R/aki.R | 2 -- R/data-aki.R | 7 +++++++ R/data-eGFR.R | 7 +++++++ data-raw/aki-data.R | 6 ++++++ data-raw/{ckd-data.R => eGFR-data.R} | 0 data/aki_pt_data.rda | Bin 0 -> 707 bytes data/eGFR_pt_data.rda | Bin 0 -> 1131 bytes man/aki_pt_data.Rd | 19 +++++++++++++++++++ man/eGFR_pt_data.Rd | 19 +++++++++++++++++++ 9 files changed, 58 insertions(+), 2 deletions(-) create mode 100644 R/data-aki.R create mode 100644 R/data-eGFR.R rename data-raw/{ckd-data.R => eGFR-data.R} (100%) create mode 100644 data/aki_pt_data.rda create mode 100644 data/eGFR_pt_data.rda create mode 100644 man/aki_pt_data.Rd create mode 100644 man/eGFR_pt_data.Rd diff --git a/R/aki.R b/R/aki.R index 9deaa3e..e2482e1 100644 --- a/R/aki.R +++ b/R/aki.R @@ -5,8 +5,6 @@ aki_stages <- factor( ordered = TRUE ) -aki_staging <- function() {} - #' Codify AKI from Serum Creatinine and/or Urine Output #' #' Using KDIGO Clinical Practice Guideline for Acute Kidney Injury 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-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/data-raw/aki-data.R b/data-raw/aki-data.R index 1a3a002..5877e96 100644 --- a/data-raw/aki-data.R +++ b/data-raw/aki-data.R @@ -1,3 +1,9 @@ +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"), diff --git a/data-raw/ckd-data.R b/data-raw/eGFR-data.R similarity index 100% rename from data-raw/ckd-data.R rename to data-raw/eGFR-data.R diff --git a/data/aki_pt_data.rda b/data/aki_pt_data.rda new file mode 100644 index 0000000000000000000000000000000000000000..dba33a51a769f5c7fbfd0c0688d26618a83fc937 GIT binary patch literal 707 zcmV;!0zCafT4*^jL0KkKS*46$2>=88fBXOc+-O8ayhQ9P+Caar->}F)06&_zyh3529yysAOHXZKr{dVXaE2Kq3Qq)2-Jkym`L`igGQ4Gz)Xw*10xW?gG_)h z2Lnws&}e9AWM~FJ8X5yl82|ttc6>Kb`Qn^EX$Jt3fGp!GB|Hm8(i zY2`H2^(UlJtktdKMlc{^xGOiE%Tmz|!JD`+ z;l+aI0;R=nlG<8Yi;A>Buu*}nL8Ob~kA(YiIa1#Z0Kp)NAfOm52jB&AR7ao4rPc4D z$9SFEdFQ$ZVuA({=U5~FL$E~VuP4<^90!j8jutJN-uHKl$90wA#uyCR{;Vl@5d>b` z06UQsvTKgLJRTTHCN5SCr#_8*IHVkUcNELdZP{|#FULT)M~f!Sa52R;gaFtDNFuRd z#9+HpK-q;Lk^znYpD6_f=$AkbR8bm~prH0+H)%rBBYn>d~T$uFvp2PC2LdD{y+)D4}qHo=3zt#t}Il&7!n6AETt0!-zK*MxuZcO+AV2?|)n@Q}JVMq~g0 literal 0 HcmV?d00001 diff --git a/data/eGFR_pt_data.rda b/data/eGFR_pt_data.rda new file mode 100644 index 0000000000000000000000000000000000000000..4e650517442994942ecf9599557035e12c55a778 GIT binary patch literal 1131 zcmV-x1eE(iT4*^jL0KkKS=;VGX8;EhfB*l#{usoWe*69X{{FxJ-uvAw7xS~FwS4^7 zp6qeHd)d$f-T*bW05T0yBR~KL=?DM-0imDJff*Sz84Q^QMwuEk$TVmHf;7-# z8UPtIGGHS?qd-)Y6v>ckOrEC6P3bh!Y@Vs6V5XXSk5Q&Hm=Mi0N2tv}%^Hm!rh^HQ zngdAnFvKHG8&d>5O*2iZf4G6)YZdZx>XMS3Mw+DB1qBOXaJvjZ+G3KGBr?V|B~>Xd z)-Gu#w)rneFG_<#+gUEKiii~_IfDCF3X{E|D}levr5dSJU0r3CNs9su*^8k}dIe#d z`i2{>LPj{OH*V>UV5f1Ez?>hynIGek;=Mx>cm5$W4u4(yG9V03{=bg zfyEE39$ma!dd>fjtmRwC%+XBYW2E<2Ti#XkkE7@8W_E)wPalq8=yujb*hJTGK4?uO(@T=RzQ6Z5i?zwE(n0O+zmvst znQm66cf$Gh%SsliSW+yBBG*#h8)f@mU%<%oAKA9kakPD}2mC)D`uIGz4{_gd(j~C% z=yVYF)edg$;`8pt0)PRE!QODX)Db@~LTEQ12ICqNyh#LObYQWdbi81C#Q^XLqtd$u za}|@|Wxlg7AE94~z`$>yl?Da7W8V0J4m(6J{y>|d1L1&lO7MK74 literal 0 HcmV?d00001 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/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} From 3c1a2ab628546a84645da19ded45f9233b18eff5 Mon Sep 17 00:00:00 2001 From: alwinw <16846521+alwinw@users.noreply.github.com> Date: Sat, 5 Jun 2021 15:12:48 +1000 Subject: [PATCH 03/18] Cleaned up code comments --- NAMESPACE | 1 + R/Txp-recipient.R | 1 - R/aki.R | 9 ++++++++- R/ckd.R | 8 +------- R/lipid.R | 2 +- R/utils.R | 17 +++++------------ man/aki_stages.Rd | 19 +++++++++++++++++++ man/combn_changes.Rd | 2 +- tests/testthat/test-anemia.R | 2 +- 9 files changed, 37 insertions(+), 24 deletions(-) create mode 100644 man/aki_stages.Rd diff --git a/NAMESPACE b/NAMESPACE index 91d5274..0970cfb 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -57,6 +57,7 @@ export(aki) export(aki_SCr) export(aki_UO) export(aki_bCr) +export(aki_stages) export(anemia) export(as_metric) export(binary2factor) 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 e2482e1..768f5c2 100644 --- a/R/aki.R +++ b/R/aki.R @@ -1,4 +1,10 @@ - +#' AKI Stages +#' +#' Ordered factor of AKI stages +#' +#' @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"), @@ -235,6 +241,7 @@ aki_SCr.numeric <- function(SCr, dttm, pt_id, ...) { dplyr::pull(.data$.aki) } + #' AKI Staging based on urine output #' #' @param .data (data.frame) A data.frame, optional diff --git a/R/ckd.R b/R/ckd.R index c3bc902..5d630c8 100644 --- a/R/ckd.R +++ b/R/ckd.R @@ -36,7 +36,6 @@ eGFR <- function(...) { UseMethod("eGFR") } - eGFR_internal <- function( SCr, SCysC, @@ -64,7 +63,6 @@ eGFR_internal <- function( } } - #' @rdname eGFR #' @export eGFR.default <- function(.data, @@ -78,7 +76,7 @@ eGFR.default <- function(.data, 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,10 +178,6 @@ eGFR.numeric <- function( dplyr::pull(eGFR) } -# Overall GFR staging - -# Overall Albuminuria staging - #' 2009 CKD-EPI creatinine equation #' 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..498c7a5 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 @@ -186,6 +182,7 @@ binary2factor <- function(.data, ...) { ) } +# Internal helper functions for combine_date_time_cols set_names <- function(.data, names) { names(.data) <- names .data @@ -267,7 +264,7 @@ 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 @@ -307,10 +304,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, ...) { @@ -330,7 +323,7 @@ combn_changes.POSIXct <- function(dttm, val, pt_id, ...) { ) %>% tidyr::drop_na() %>% dplyr::group_by(.data$admin, .add = TRUE) - # check for nrow < 2 + # [ ]: check for nrow < 2 data_n <- data_gr %>% dplyr::count() %>% dplyr::ungroup() %>% @@ -338,7 +331,7 @@ combn_changes.POSIXct <- function(dttm, val, pt_id, ...) { 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 @@ -354,5 +347,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/man/aki_stages.Rd b/man/aki_stages.Rd new file mode 100644 index 0000000..ea9274f --- /dev/null +++ b/man/aki_stages.Rd @@ -0,0 +1,19 @@ +% 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 +} +\examples{ +aki_stages +} +\keyword{datasets} diff --git a/man/combn_changes.Rd b/man/combn_changes.Rd index a794e48..ce0df67 100644 --- a/man/combn_changes.Rd +++ b/man/combn_changes.Rd @@ -31,7 +31,7 @@ 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") 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() ) From bcdab2056d61f007f11d7a6f0338173e4c339946 Mon Sep 17 00:00:00 2001 From: alwinw <16846521+alwinw@users.noreply.github.com> Date: Sat, 5 Jun 2021 15:16:10 +1000 Subject: [PATCH 04/18] Bumped version and (c) year --- DESCRIPTION | 2 +- LICENSE | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) 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 From 4494302f7b67e43568a6f667c850d9341bb2b1d5 Mon Sep 17 00:00:00 2001 From: alwinw <16846521+alwinw@users.noreply.github.com> Date: Sat, 5 Jun 2021 15:25:18 +1000 Subject: [PATCH 05/18] Renamed aki() to aki_staging() --- NAMESPACE | 8 ++--- R/aki.R | 66 +++++++++++++++++----------------- man/{aki.Rd => aki_staging.Rd} | 32 ++++++++++------- tests/testthat/test-aki.R | 24 ++++++------- 4 files changed, 69 insertions(+), 61 deletions(-) rename man/{aki.Rd => aki_staging.Rd} (61%) diff --git a/NAMESPACE b/NAMESPACE index 0970cfb..6001a0e 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -9,9 +9,6 @@ S3method(Albuminuria_staging_AER,units) S3method(GFR_staging,default) S3method(GFR_staging,numeric) S3method(GFR_staging,units) -S3method(aki,default) -S3method(aki,numeric) -S3method(aki,units) S3method(aki_SCr,default) S3method(aki_SCr,numeric) S3method(aki_SCr,units) @@ -21,6 +18,9 @@ S3method(aki_UO,units) S3method(aki_bCr,default) S3method(aki_bCr,numeric) S3method(aki_bCr,units) +S3method(aki_staging,default) +S3method(aki_staging,numeric) +S3method(aki_staging,units) S3method(anemia,default) S3method(anemia,numeric) S3method(anemia,units) @@ -53,11 +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) diff --git a/R/aki.R b/R/aki.R index 768f5c2..0a83f76 100644 --- a/R/aki.R +++ b/R/aki.R @@ -16,9 +16,9 @@ aki_stages <- factor( #' 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 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 #' #' @param .data (data.frame) A data.frame, optional #' @param SCr Serum creatinine @@ -38,20 +38,20 @@ aki_stages <- factor( #' @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.default <- 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))]] @@ -60,42 +60,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)) { diff --git a/man/aki.Rd b/man/aki_staging.Rd similarity index 61% rename from man/aki.Rd rename to man/aki_staging.Rd index be509e0..63ff8e7 100644 --- a/man/aki.Rd +++ b/man/aki_staging.Rd @@ -1,19 +1,27 @@ % 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} +\name{aki_staging} +\alias{aki_staging} +\alias{aki_staging.default} +\alias{aki_staging.units} +\alias{aki_staging.numeric} \title{Codify AKI from Serum Creatinine and/or Urine Output} \usage{ -aki(...) +aki_staging(...) -\method{aki}{default}(.data, SCr = NULL, bCr = NULL, UO = NULL, dttm = NULL, pt_id = NULL, ...) +\method{aki_staging}{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_staging}{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, ...) +\method{aki_staging}{numeric}(SCr = NULL, bCr = NULL, UO = NULL, dttm = NULL, pt_id = NULL, ...) } \arguments{ \item{...}{Further optional arguments} @@ -40,9 +48,9 @@ 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 +Provided a 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 } \examples{ print("todo") diff --git a/tests/testthat/test-aki.R b/tests/testthat/test-aki.R index 2fdffee..c08cfb3 100644 --- a/tests/testthat/test-aki.R +++ b/tests/testthat/test-aki.R @@ -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 ) }) From 732affd5a14246d4dd9f229de32604f7d3419d07 Mon Sep 17 00:00:00 2001 From: alwinw <16846521+alwinw@users.noreply.github.com> Date: Sat, 5 Jun 2021 15:48:50 +1000 Subject: [PATCH 06/18] Added examples to aki docs --- R/aki.R | 60 +++++++++++++++++++++++++++++++++++++++------- man/aki_SCr.Rd | 17 ++++++++++--- man/aki_UO.Rd | 17 ++++++++++--- man/aki_bCr.Rd | 17 ++++++++++--- man/aki_staging.Rd | 11 +++++++-- 5 files changed, 103 insertions(+), 19 deletions(-) diff --git a/R/aki.R b/R/aki.R index 0a83f76..35217db 100644 --- a/R/aki.R +++ b/R/aki.R @@ -17,9 +17,13 @@ aki_stages <- factor( #' Volume 2 | Issue 1 | March 2012 #' #' Provided a series of Serum Creatinine readings and/or Urine Output, -#' #' aki_staging() calculates whether or not a patient has AKI. +#' `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. +#' The most severe AKI stage is then returned. +#' #' @param .data (data.frame) A data.frame, optional #' @param SCr Serum creatinine #' column name, or vector if `.data` not provided @@ -34,7 +38,10 @@ aki_stages <- factor( #' @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 @@ -122,7 +129,16 @@ aki_staging.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} +#' } #' #' @param .data (data.frame) A data.frame, optional #' @param SCr Serum creatinine @@ -135,7 +151,10 @@ aki_staging.numeric <- function( #' @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") } @@ -174,7 +193,16 @@ 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)} +#' } #' #' @param .data (data.frame) A data.frame, optional #' @param dttm DateTime @@ -189,7 +217,10 @@ aki_bCr.numeric <- function(SCr, bCr, ...) { #' @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") } @@ -224,6 +255,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) ) ) %>% @@ -242,7 +274,16 @@ aki_SCr.numeric <- function(SCr, dttm, pt_id, ...) { } -#' 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} +#' } #' #' @param .data (data.frame) A data.frame, optional #' @param dttm DateTime @@ -257,7 +298,10 @@ aki_SCr.numeric <- function(SCr, dttm, pt_id, ...) { #' @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") } diff --git a/man/aki_SCr.Rd b/man/aki_SCr.Rd index 2d60dcc..398620f 100644 --- a/man/aki_SCr.Rd +++ b/man/aki_SCr.Rd @@ -5,7 +5,7 @@ \alias{aki_SCr.default} \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(...) @@ -33,8 +33,19 @@ column name, or vector if \code{.data} not provided} (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)} +} } \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..c3c559f 100644 --- a/man/aki_UO.Rd +++ b/man/aki_UO.Rd @@ -5,7 +5,7 @@ \alias{aki_UO.default} \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(...) @@ -33,8 +33,19 @@ column name, or vector if \code{.data} not provided} (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} +} } \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..f8352e5 100644 --- a/man/aki_bCr.Rd +++ b/man/aki_bCr.Rd @@ -5,7 +5,7 @@ \alias{aki_bCr.default} \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(...) @@ -30,8 +30,19 @@ column name, or vector if \code{.data} not provided} (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} +} } \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_staging.Rd b/man/aki_staging.Rd index 63ff8e7..a1ec365 100644 --- a/man/aki_staging.Rd +++ b/man/aki_staging.Rd @@ -49,9 +49,16 @@ Volume 2 | Issue 1 | March 2012 } \details{ Provided a series of Serum Creatinine readings and/or Urine Output, -#' aki_staging() calculates whether or not a patient has AKI. +\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. +The most severe AKI stage is then returned. } \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_)) } From b1a0471623216403e96e1f86800eca72bcd629b0 Mon Sep 17 00:00:00 2001 From: alwinw <16846521+alwinw@users.noreply.github.com> Date: Sat, 5 Jun 2021 15:56:29 +1000 Subject: [PATCH 07/18] Added anemia example data --- R/data-anemia.R | 7 +++++++ data-raw/anemia-data.R | 24 ++++++++++++++++++++++++ data/anemia_pt_data.rda | Bin 0 -> 310 bytes man/anemia_pt_data.Rd | 19 +++++++++++++++++++ 4 files changed, 50 insertions(+) create mode 100644 R/data-anemia.R create mode 100644 data-raw/anemia-data.R create mode 100644 data/anemia_pt_data.rda create mode 100644 man/anemia_pt_data.Rd diff --git a/R/data-anemia.R b/R/data-anemia.R new file mode 100644 index 0000000..e29fc30 --- /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" \ No newline at end of file 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/anemia_pt_data.rda b/data/anemia_pt_data.rda new file mode 100644 index 0000000000000000000000000000000000000000..fa7e1abd8f9c72fdd53a10df96a266d29ab0257b GIT binary patch literal 310 zcmV-60m=SCT4*^jL0KkKS#R@}i~s>Sf589yNCX4<6aYj(5J11D-k?AL0RgZ9EGmSl zq!Uk5(K290fB*)JhK4jWGyr5Y00000NTWoLN@z4127nlvGy}>-8xo1=DV~Z)^FE4m z3rUefNQ4m(LTZPcBT|9WMIf1;gn(^V4uWgtr)`*$a~gXZy9*?dRyCzEB_UZ!BaPR9C#_ukqb^ zJVt1tn~#vCQBzrY2|!glLwp1bTl|*-hiflcqV Date: Sat, 5 Jun 2021 16:03:25 +1000 Subject: [PATCH 08/18] Added examples to anemia docs --- R/anemia.R | 18 +++++++++++++++++- R/data-anemia.R | 2 +- man/anemia.Rd | 19 +++++++++++++++++-- 3 files changed, 35 insertions(+), 4 deletions(-) diff --git a/R/anemia.R b/R/anemia.R index e50837f..634b4cd 100644 --- a/R/anemia.R +++ b/R/anemia.R @@ -1,5 +1,18 @@ #' 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.} +#' } +#' #' @param .data (data.frame) A data.frame, optional #' @param Hb Hemoglobin concenration #' column name, or vector if `.data` not provided @@ -14,7 +27,10 @@ #' @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") } diff --git a/R/data-anemia.R b/R/data-anemia.R index e29fc30..342f9c2 100644 --- a/R/data-anemia.R +++ b/R/data-anemia.R @@ -4,4 +4,4 @@ #' #' @examples #' anemia_pt_data -"anemia_pt_data" \ No newline at end of file +"anemia_pt_data" diff --git a/man/anemia.Rd b/man/anemia.Rd index 3bb3dad..ccd83b7 100644 --- a/man/anemia.Rd +++ b/man/anemia.Rd @@ -34,8 +34,23 @@ 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.} +} } \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)) } From ca6bfcf43c58153e8457bafae744be38b7edcbfe Mon Sep 17 00:00:00 2001 From: alwinw <16846521+alwinw@users.noreply.github.com> Date: Sat, 5 Jun 2021 16:37:13 +1000 Subject: [PATCH 09/18] Added explanations to eGFR and Alb --- R/aki.R | 35 ++++- R/anemia.R | 5 +- R/ckd.R | 236 ++++++++++++++++++++++++++++++--- man/Albuminuria_stages.Rd | 9 ++ man/Albuminuria_staging_ACR.Rd | 22 ++- man/Albuminuria_staging_AER.Rd | 22 ++- man/GFR_stages.Rd | 3 + man/GFR_staging.Rd | 25 +++- man/aki_SCr.Rd | 5 +- man/aki_UO.Rd | 5 +- man/aki_bCr.Rd | 5 +- man/aki_stages.Rd | 3 + man/aki_staging.Rd | 18 ++- man/anemia.Rd | 5 +- man/eGFR.Rd | 34 +++-- man/eGFR_adult_SCr.Rd | 22 ++- man/eGFR_adult_SCr_SCysC.Rd | 22 ++- man/eGFR_adult_SCysC.Rd | 22 ++- man/eGFR_child_SCr.Rd | 22 ++- man/eGFR_child_SCr_BUN.Rd | 22 ++- man/eGFR_child_SCysC.Rd | 22 ++- 21 files changed, 495 insertions(+), 69 deletions(-) diff --git a/R/aki.R b/R/aki.R index 35217db..ac8896c 100644 --- a/R/aki.R +++ b/R/aki.R @@ -2,6 +2,8 @@ #' #' Ordered factor of AKI stages #' +#' See for more details +#' #' @export #' @examples #' aki_stages @@ -13,17 +15,27 @@ aki_stages <- factor( #' 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_staging()` calculates whether or not a patient has AKI. -#' The staging (1, 2, 3) of AKI is returned +#' 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 @@ -131,7 +143,8 @@ aki_staging.numeric <- function( #' AKI Staging based on Baseline Serum Creatinine #' -#' Using KDIGO Clinical Practice Guideline for Acute Kidney Injury +#' Using KDIGO Clinical Practice Guideline for +#' Acute Kidney Injury #' Volume 2 | Issue 1 | March 2012 #' #' \itemize{ @@ -140,6 +153,8 @@ aki_staging.numeric <- function( #' \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 @@ -195,7 +210,8 @@ aki_bCr.numeric <- function(SCr, bCr, ...) { #' AKI Staging based on Changes in Serum Creatinine #' -#' Using KDIGO Clinical Practice Guideline for Acute Kidney Injury +#' Using KDIGO Clinical Practice Guideline for +#' Acute Kidney Injury #' Volume 2 | Issue 1 | March 2012 #' #' \itemize{ @@ -204,6 +220,8 @@ aki_bCr.numeric <- function(SCr, bCr, ...) { #' \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 @@ -276,7 +294,8 @@ aki_SCr.numeric <- function(SCr, dttm, pt_id, ...) { #' AKI Staging based on 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 #' #' \itemize{ @@ -285,6 +304,8 @@ aki_SCr.numeric <- function(SCr, dttm, pt_id, ...) { #' \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 diff --git a/R/anemia.R b/R/anemia.R index 634b4cd..3981173 100644 --- a/R/anemia.R +++ b/R/anemia.R @@ -1,6 +1,7 @@ #' Diagnosis of anemia from Hb concentration #' -#' KDIGO Clinical Practice Guideline for Anemia in Chronic Kidney Disease +#' KDIGO Clinical Practice Guideline for +#' Anemia in Chronic Kidney Disease #' Volume 2 | Issue 4 | August (2) 2012 #' #' \itemize{ @@ -13,6 +14,8 @@ #' 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 diff --git a/R/ckd.R b/R/ckd.R index 5d630c8..6e6dba4 100644 --- a/R/ckd.R +++ b/R/ckd.R @@ -1,11 +1,22 @@ #' 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 @@ -31,7 +42,18 @@ #' @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") } @@ -179,7 +201,13 @@ eGFR.numeric <- function( } -#' 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 @@ -197,7 +225,18 @@ eGFR.numeric <- function( #' @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_adult_SCr <- function(...) { UseMethod("eGFR_adult_SCr") } @@ -241,7 +280,13 @@ 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 @@ -257,7 +302,18 @@ eGFR_adult_SCr.numeric <- function(SCr, Age, male, black, ...) { #' @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_adult_SCysC <- function(...) { UseMethod("eGFR_adult_SCysC") } @@ -295,7 +351,13 @@ 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 @@ -315,7 +377,18 @@ eGFR_adult_SCysC.numeric <- function(SCysC, Age, male, ...) { #' @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_adult_SCr_SCysC <- function(...) { UseMethod("eGFR_adult_SCr_SCysC") } @@ -363,7 +436,13 @@ 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 @@ -377,7 +456,18 @@ eGFR_adult_SCr_SCysC.numeric <- function(SCr, SCysC, Age, male, black, ...) { #' @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_child_SCr <- function(...) { UseMethod("eGFR_child_SCr") } @@ -411,7 +501,13 @@ 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 @@ -427,7 +523,18 @@ eGFR_child_SCr.numeric <- function(SCr, height, ...) { #' @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_child_SCr_BUN <- function(...) { UseMethod("eGFR_child_SCr_BUN") } @@ -463,7 +570,13 @@ 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 @@ -475,7 +588,18 @@ eGFR_child_SCr_BUN.numeric <- function(SCr, height, BUN, ...) { #' @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_child_SCysC <- function(...) { UseMethod("eGFR_child_SCysC") } @@ -511,6 +635,8 @@ eGFR_child_SCysC.numeric <- function(SCysC, ...) { #' #' Ordered factor of GFR stages #' +#' See for more details +#' #' @export #' @examples #' GFR_stages @@ -519,6 +645,21 @@ 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 @@ -528,7 +669,14 @@ GFR_stages <- factor(c("G1", "G2", "G3a", "G3b", "G4", "G5"), ordered = TRUE) #' @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") } @@ -571,6 +719,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 @@ -583,6 +739,18 @@ 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 @@ -592,7 +760,14 @@ Albuminuria_stages <- factor( #' @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") } @@ -627,6 +802,18 @@ 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 @@ -636,7 +823,14 @@ Albuminuria_staging_AER.numeric <- function(AER, ...) { #' @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") } 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..f2b4a95 100644 --- a/man/Albuminuria_staging_ACR.Rd +++ b/man/Albuminuria_staging_ACR.Rd @@ -27,8 +27,26 @@ column name, or vector if \code{.data} not provided} 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..a920ddb 100644 --- a/man/Albuminuria_staging_AER.Rd +++ b/man/Albuminuria_staging_AER.Rd @@ -27,8 +27,26 @@ column name, or vector if \code{.data} not provided} 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..db5be9d 100644 --- a/man/GFR_staging.Rd +++ b/man/GFR_staging.Rd @@ -27,8 +27,29 @@ column name, or vector if \code{.data} not provided} 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_SCr.Rd b/man/aki_SCr.Rd index 398620f..e79e230 100644 --- a/man/aki_SCr.Rd +++ b/man/aki_SCr.Rd @@ -33,7 +33,8 @@ column name, or vector if \code{.data} not provided} (ordered factor) AKI stages } \description{ -Using KDIGO Clinical Practice Guideline for Acute Kidney Injury +Using KDIGO Clinical Practice Guideline for +Acute Kidney Injury Volume 2 | Issue 1 | March 2012 } \details{ @@ -42,6 +43,8 @@ Volume 2 | Issue 1 | March 2012 \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{ aki_SCr(aki_pt_data, SCr = "SCr_", dttm = "dttm_", pt_id = "pt_id_") diff --git a/man/aki_UO.Rd b/man/aki_UO.Rd index c3c559f..2beae37 100644 --- a/man/aki_UO.Rd +++ b/man/aki_UO.Rd @@ -33,7 +33,8 @@ column name, or vector if \code{.data} not provided} (ordered factor) AKI stages } \description{ -Using KDIGO Clinical Practice Guideline for Acute Kidney Injury +Using KDIGO Clinical Practice Guideline for +Acute Kidney Injury Volume 2 | Issue 1 | March 2012 } \details{ @@ -42,6 +43,8 @@ Volume 2 | Issue 1 | March 2012 \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{ aki_UO(aki_pt_data, UO = "UO_", dttm = "dttm_", pt_id = "pt_id_") diff --git a/man/aki_bCr.Rd b/man/aki_bCr.Rd index f8352e5..0e4df8a 100644 --- a/man/aki_bCr.Rd +++ b/man/aki_bCr.Rd @@ -30,7 +30,8 @@ column name, or vector if \code{.data} not provided} (ordered factor) AKI stages } \description{ -Using KDIGO Clinical Practice Guideline for Acute Kidney Injury +Using KDIGO Clinical Practice Guideline for +Acute Kidney Injury Volume 2 | Issue 1 | March 2012 } \details{ @@ -39,6 +40,8 @@ Volume 2 | Issue 1 | March 2012 \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{ aki_bCr(aki_pt_data, SCr = "SCr_", bCr = "bCr_") diff --git a/man/aki_stages.Rd b/man/aki_stages.Rd index ea9274f..c4a929c 100644 --- a/man/aki_stages.Rd +++ b/man/aki_stages.Rd @@ -13,6 +13,9 @@ 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 } diff --git a/man/aki_staging.Rd b/man/aki_staging.Rd index a1ec365..18248fb 100644 --- a/man/aki_staging.Rd +++ b/man/aki_staging.Rd @@ -44,17 +44,27 @@ column name, or vector if \code{.data} not provided} column name, or vector if \code{.data} not provided} } \description{ -Using KDIGO Clinical Practice Guideline for Acute Kidney Injury +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, -\code{aki_staging()} calculates whether or not a patient has AKI. -The staging (1, 2, 3) of AKI is returned +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_") diff --git a/man/anemia.Rd b/man/anemia.Rd index ccd83b7..743de6a 100644 --- a/man/anemia.Rd +++ b/man/anemia.Rd @@ -34,7 +34,8 @@ Anemia as logical \code{TRUE} or \code{FALSE} } \description{ -KDIGO Clinical Practice Guideline for Anemia in Chronic Kidney Disease +KDIGO Clinical Practice Guideline for +Anemia in Chronic Kidney Disease Volume 2 | Issue 4 | August (2) 2012 } \details{ @@ -47,6 +48,8 @@ Volume 2 | Issue 4 | August (2) 2012 <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{ anemia(anemia_pt_data, Hb = "Hb", age = "age", male = "male") diff --git a/man/eGFR.Rd b/man/eGFR.Rd index 3b69cff..4f368c7 100644 --- a/man/eGFR.Rd +++ b/man/eGFR.Rd @@ -80,18 +80,36 @@ column name, or vector if \code{.data} not provided} 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..0291d72 100644 --- a/man/eGFR_adult_SCr.Rd +++ b/man/eGFR_adult_SCr.Rd @@ -5,7 +5,7 @@ \alias{eGFR_adult_SCr.default} \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(...) @@ -37,8 +37,24 @@ 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(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_SCysC.Rd b/man/eGFR_adult_SCr_SCysC.Rd index c2b5b35..7cba4f8 100644 --- a/man/eGFR_adult_SCr_SCysC.Rd +++ b/man/eGFR_adult_SCr_SCysC.Rd @@ -5,7 +5,7 @@ \alias{eGFR_adult_SCr_SCysC.default} \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(...) @@ -40,8 +40,24 @@ 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(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_SCysC.Rd b/man/eGFR_adult_SCysC.Rd index 0bb7d96..a06efca 100644 --- a/man/eGFR_adult_SCysC.Rd +++ b/man/eGFR_adult_SCysC.Rd @@ -5,7 +5,7 @@ \alias{eGFR_adult_SCysC.default} \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(...) @@ -34,8 +34,24 @@ 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(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_child_SCr.Rd b/man/eGFR_child_SCr.Rd index 07a213c..75021db 100644 --- a/man/eGFR_child_SCr.Rd +++ b/man/eGFR_child_SCr.Rd @@ -5,7 +5,7 @@ \alias{eGFR_child_SCr.default} \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(...) @@ -31,8 +31,24 @@ 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(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_child_SCr_BUN.Rd b/man/eGFR_child_SCr_BUN.Rd index 67c64f5..53f4a06 100644 --- a/man/eGFR_child_SCr_BUN.Rd +++ b/man/eGFR_child_SCr_BUN.Rd @@ -5,7 +5,7 @@ \alias{eGFR_child_SCr_BUN.default} \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(...) @@ -34,8 +34,24 @@ 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(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_child_SCysC.Rd b/man/eGFR_child_SCysC.Rd index 9dd77bc..bbea1c3 100644 --- a/man/eGFR_child_SCysC.Rd +++ b/man/eGFR_child_SCysC.Rd @@ -5,7 +5,7 @@ \alias{eGFR_child_SCysC.default} \alias{eGFR_child_SCysC.units} \alias{eGFR_child_SCysC.numeric} -\title{Pediatric SCysC} +\title{eGFR Pediatric SCysC} \usage{ eGFR_child_SCysC(...) @@ -28,8 +28,24 @@ 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(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_ + )) } From 65dac50926ca02697453b00917da48c5c25f3349 Mon Sep 17 00:00:00 2001 From: alwinw <16846521+alwinw@users.noreply.github.com> Date: Sat, 5 Jun 2021 16:47:22 +1000 Subject: [PATCH 10/18] Added examples to eGFR methods --- R/ckd.R | 84 ++++++++++++++----------------------- man/eGFR.Rd | 2 +- man/eGFR_adult_SCr.Rd | 14 +++---- man/eGFR_adult_SCr_SCysC.Rd | 12 +++--- man/eGFR_adult_SCysC.Rd | 14 +++---- man/eGFR_child_SCr.Rd | 14 +++---- man/eGFR_child_SCr_BUN.Rd | 14 +++---- man/eGFR_child_SCysC.Rd | 14 +++---- tests/testthat/test-ckd.R | 2 + 9 files changed, 64 insertions(+), 106 deletions(-) diff --git a/R/ckd.R b/R/ckd.R index 6e6dba4..d699334 100644 --- a/R/ckd.R +++ b/R/ckd.R @@ -53,7 +53,7 @@ #' SCr = SCr_, SCysC = SCysC_, #' Age = Age_, height = height_, BUN = BUN_, #' male = male_, black = black_, pediatric = pediatric_ -#' )) +#' )) eGFR <- function(...) { UseMethod("eGFR") } @@ -225,18 +225,14 @@ eGFR.numeric <- function( #' @export #' #' @examples -#' eGFR(eGFR_pt_data, -#' SCr = "SCr_", SCysC = "SCysC_", -#' Age = "Age_", height = "height_", BUN = "BUN_", -#' male = "male_", black = "black_", pediatric = "pediatric_" +#' eGFR_adult_SCr(eGFR_pt_data, +#' SCr = "SCr_", Age = "Age_", male = "male_", black = "black_" #' ) #' #' eGFR_pt_data %>% -#' dplyr::mutate(eGFR = eGFR( -#' SCr = SCr_, SCysC = SCysC_, -#' Age = Age_, height = height_, BUN = BUN_, -#' male = male_, black = black_, pediatric = pediatric_ -#' )) +#' dplyr::mutate(eGFR = eGFR_adult_SCr( +#' SCr = SCr_, Age = Age_, male = male_, black = black_ +#' )) eGFR_adult_SCr <- function(...) { UseMethod("eGFR_adult_SCr") } @@ -302,18 +298,14 @@ eGFR_adult_SCr.numeric <- function(SCr, Age, male, black, ...) { #' @export #' #' @examples -#' eGFR(eGFR_pt_data, -#' SCr = "SCr_", SCysC = "SCysC_", -#' Age = "Age_", height = "height_", BUN = "BUN_", -#' male = "male_", black = "black_", pediatric = "pediatric_" +#' eGFR_adult_SCysC(eGFR_pt_data, +#' SCysC = "SCysC_", Age = "Age_", male = "male_" #' ) #' #' eGFR_pt_data %>% -#' dplyr::mutate(eGFR = eGFR( -#' SCr = SCr_, SCysC = SCysC_, -#' Age = Age_, height = height_, BUN = BUN_, -#' male = male_, black = black_, pediatric = pediatric_ -#' )) +#' dplyr::mutate(eGFR = eGFR_adult_SCysC( +#' SCysC = SCysC_,Age = Age_, male = male_ +#' )) eGFR_adult_SCysC <- function(...) { UseMethod("eGFR_adult_SCysC") } @@ -377,18 +369,16 @@ eGFR_adult_SCysC.numeric <- function(SCysC, Age, male, ...) { #' @export #' #' @examples -#' eGFR(eGFR_pt_data, +#' eGFR_adult_SCr_SCysC(eGFR_pt_data, #' SCr = "SCr_", SCysC = "SCysC_", -#' Age = "Age_", height = "height_", BUN = "BUN_", -#' male = "male_", black = "black_", pediatric = "pediatric_" +#' Age = "Age_", male = "male_", black = "black_" #' ) #' #' eGFR_pt_data %>% -#' dplyr::mutate(eGFR = eGFR( +#' dplyr::mutate(eGFR = eGFR_adult_SCr_SCysC( #' SCr = SCr_, SCysC = SCysC_, -#' Age = Age_, height = height_, BUN = BUN_, -#' male = male_, black = black_, pediatric = pediatric_ -#' )) +#' Age = Age_, male = male_, black = black_ +#' )) eGFR_adult_SCr_SCysC <- function(...) { UseMethod("eGFR_adult_SCr_SCysC") } @@ -456,18 +446,14 @@ eGFR_adult_SCr_SCysC.numeric <- function(SCr, SCysC, Age, male, black, ...) { #' @export #' #' @examples -#' eGFR(eGFR_pt_data, -#' SCr = "SCr_", SCysC = "SCysC_", -#' Age = "Age_", height = "height_", BUN = "BUN_", -#' male = "male_", black = "black_", pediatric = "pediatric_" +#' eGFR_child_SCr(eGFR_pt_data, +#' SCr = "SCr_", height = "height_" #' ) #' #' eGFR_pt_data %>% -#' dplyr::mutate(eGFR = eGFR( -#' SCr = SCr_, SCysC = SCysC_, -#' Age = Age_, height = height_, BUN = BUN_, -#' male = male_, black = black_, pediatric = pediatric_ -#' )) +#' dplyr::mutate(eGFR = eGFR_child_SCr( +#' SCr = SCr_, height = height_, +#' )) eGFR_child_SCr <- function(...) { UseMethod("eGFR_child_SCr") } @@ -523,18 +509,14 @@ eGFR_child_SCr.numeric <- function(SCr, height, ...) { #' @export #' #' @examples -#' eGFR(eGFR_pt_data, -#' SCr = "SCr_", SCysC = "SCysC_", -#' Age = "Age_", height = "height_", BUN = "BUN_", -#' male = "male_", black = "black_", pediatric = "pediatric_" +#' eGFR_child_SCr_BUN(eGFR_pt_data, +#' SCr = "SCr_", height = "height_", BUN = "BUN_", #' ) #' #' eGFR_pt_data %>% -#' dplyr::mutate(eGFR = eGFR( -#' SCr = SCr_, SCysC = SCysC_, -#' Age = Age_, height = height_, BUN = BUN_, -#' male = male_, black = black_, pediatric = pediatric_ -#' )) +#' dplyr::mutate(eGFR = eGFR_child_SCr_BUN( +#' SCr = SCr_, height = height_, BUN = BUN_, +#' )) eGFR_child_SCr_BUN <- function(...) { UseMethod("eGFR_child_SCr_BUN") } @@ -588,18 +570,14 @@ eGFR_child_SCr_BUN.numeric <- function(SCr, height, BUN, ...) { #' @export #' #' @examples -#' eGFR(eGFR_pt_data, -#' SCr = "SCr_", SCysC = "SCysC_", -#' Age = "Age_", height = "height_", BUN = "BUN_", -#' male = "male_", black = "black_", pediatric = "pediatric_" +#' eGFR_child_SCysC(eGFR_pt_data, +#' SCysC = "SCysC_" #' ) #' #' eGFR_pt_data %>% -#' dplyr::mutate(eGFR = eGFR( -#' SCr = SCr_, SCysC = SCysC_, -#' Age = Age_, height = height_, BUN = BUN_, -#' male = male_, black = black_, pediatric = pediatric_ -#' )) +#' dplyr::mutate(eGFR = eGFR_child_SCysC( +#' SCysC = SCysC_ +#' )) eGFR_child_SCysC <- function(...) { UseMethod("eGFR_child_SCysC") } diff --git a/man/eGFR.Rd b/man/eGFR.Rd index 4f368c7..07a0cf7 100644 --- a/man/eGFR.Rd +++ b/man/eGFR.Rd @@ -111,5 +111,5 @@ eGFR_pt_data \%>\% 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 0291d72..14167c9 100644 --- a/man/eGFR_adult_SCr.Rd +++ b/man/eGFR_adult_SCr.Rd @@ -45,16 +45,12 @@ Volume 3 | Issue 1 | January 2013 See \url{https://kdigo.org/guidelines/ckd-evaluation-and-management/} for more details } \examples{ -eGFR(eGFR_pt_data, - SCr = "SCr_", SCysC = "SCysC_", - Age = "Age_", height = "height_", BUN = "BUN_", - male = "male_", black = "black_", pediatric = "pediatric_" +eGFR_adult_SCr(eGFR_pt_data, + SCr = "SCr_", Age = "Age_", male = "male_", black = "black_" ) eGFR_pt_data \%>\% - dplyr::mutate(eGFR = eGFR( - SCr = SCr_, SCysC = SCysC_, - Age = Age_, height = height_, BUN = BUN_, - male = male_, black = black_, pediatric = pediatric_ - )) + 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 7cba4f8..cf828e3 100644 --- a/man/eGFR_adult_SCr_SCysC.Rd +++ b/man/eGFR_adult_SCr_SCysC.Rd @@ -48,16 +48,14 @@ Volume 3 | Issue 1 | January 2013 See \url{https://kdigo.org/guidelines/ckd-evaluation-and-management/} for more details } \examples{ -eGFR(eGFR_pt_data, +eGFR_adult_SCr_SCysC(eGFR_pt_data, SCr = "SCr_", SCysC = "SCysC_", - Age = "Age_", height = "height_", BUN = "BUN_", - male = "male_", black = "black_", pediatric = "pediatric_" + Age = "Age_", male = "male_", black = "black_" ) eGFR_pt_data \%>\% - dplyr::mutate(eGFR = eGFR( + dplyr::mutate(eGFR = eGFR_adult_SCr_SCysC( SCr = SCr_, SCysC = SCysC_, - Age = Age_, height = height_, BUN = BUN_, - male = male_, black = black_, pediatric = pediatric_ - )) + Age = Age_, male = male_, black = black_ +)) } diff --git a/man/eGFR_adult_SCysC.Rd b/man/eGFR_adult_SCysC.Rd index a06efca..6248af8 100644 --- a/man/eGFR_adult_SCysC.Rd +++ b/man/eGFR_adult_SCysC.Rd @@ -42,16 +42,12 @@ Volume 3 | Issue 1 | January 2013 See \url{https://kdigo.org/guidelines/ckd-evaluation-and-management/} for more details } \examples{ -eGFR(eGFR_pt_data, - SCr = "SCr_", SCysC = "SCysC_", - Age = "Age_", height = "height_", BUN = "BUN_", - male = "male_", black = "black_", pediatric = "pediatric_" +eGFR_adult_SCysC(eGFR_pt_data, + SCysC = "SCysC_", Age = "Age_", male = "male_" ) eGFR_pt_data \%>\% - dplyr::mutate(eGFR = eGFR( - SCr = SCr_, SCysC = SCysC_, - Age = Age_, height = height_, BUN = BUN_, - male = male_, black = black_, pediatric = pediatric_ - )) + 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 75021db..deaf819 100644 --- a/man/eGFR_child_SCr.Rd +++ b/man/eGFR_child_SCr.Rd @@ -39,16 +39,12 @@ Volume 3 | Issue 1 | January 2013 See \url{https://kdigo.org/guidelines/ckd-evaluation-and-management/} for more details } \examples{ -eGFR(eGFR_pt_data, - SCr = "SCr_", SCysC = "SCysC_", - Age = "Age_", height = "height_", BUN = "BUN_", - male = "male_", black = "black_", pediatric = "pediatric_" +eGFR_child_SCr(eGFR_pt_data, + SCr = "SCr_", height = "height_" ) eGFR_pt_data \%>\% - dplyr::mutate(eGFR = eGFR( - SCr = SCr_, SCysC = SCysC_, - Age = Age_, height = height_, BUN = BUN_, - male = male_, black = black_, pediatric = pediatric_ - )) + 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 53f4a06..2379e04 100644 --- a/man/eGFR_child_SCr_BUN.Rd +++ b/man/eGFR_child_SCr_BUN.Rd @@ -42,16 +42,12 @@ Volume 3 | Issue 1 | January 2013 See \url{https://kdigo.org/guidelines/ckd-evaluation-and-management/} for more details } \examples{ -eGFR(eGFR_pt_data, - SCr = "SCr_", SCysC = "SCysC_", - Age = "Age_", height = "height_", BUN = "BUN_", - male = "male_", black = "black_", pediatric = "pediatric_" +eGFR_child_SCr_BUN(eGFR_pt_data, + SCr = "SCr_", height = "height_", BUN = "BUN_", ) eGFR_pt_data \%>\% - dplyr::mutate(eGFR = eGFR( - SCr = SCr_, SCysC = SCysC_, - Age = Age_, height = height_, BUN = BUN_, - male = male_, black = black_, pediatric = pediatric_ - )) + 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 bbea1c3..14d5d54 100644 --- a/man/eGFR_child_SCysC.Rd +++ b/man/eGFR_child_SCysC.Rd @@ -36,16 +36,12 @@ Volume 3 | Issue 1 | January 2013 See \url{https://kdigo.org/guidelines/ckd-evaluation-and-management/} for more details } \examples{ -eGFR(eGFR_pt_data, - SCr = "SCr_", SCysC = "SCysC_", - Age = "Age_", height = "height_", BUN = "BUN_", - male = "male_", black = "black_", pediatric = "pediatric_" +eGFR_child_SCysC(eGFR_pt_data, + SCysC = "SCysC_" ) eGFR_pt_data \%>\% - dplyr::mutate(eGFR = eGFR( - SCr = SCr_, SCysC = SCysC_, - Age = Age_, height = height_, BUN = BUN_, - male = male_, black = black_, pediatric = pediatric_ - )) + dplyr::mutate(eGFR = eGFR_child_SCysC( + SCysC = SCysC_ +)) } diff --git a/tests/testthat/test-ckd.R b/tests/testthat/test-ckd.R index 6d16466..dfddb25 100644 --- a/tests/testthat/test-ckd.R +++ b/tests/testthat/test-ckd.R @@ -439,3 +439,5 @@ test_that("Albuminuria_staging_ACR()", { expect_identical(df_uvec, ep) expect_identical(df_nvec, ep) }) + +# TODO: change from x.default to x.data.frame From 364f068b1f763da24c91cfbb5e4e6b5498382017 Mon Sep 17 00:00:00 2001 From: alwinw <16846521+alwinw@users.noreply.github.com> Date: Sun, 6 Jun 2021 09:31:55 +1000 Subject: [PATCH 11/18] Added .Rprofile --- .Rprofile | 11 +++++++++++ .gitignore | 1 - R/ckd.R | 20 ++++++++++---------- 3 files changed, 21 insertions(+), 11 deletions(-) create mode 100644 .Rprofile diff --git a/.Rprofile b/.Rprofile new file mode 100644 index 0000000..5b2bfa0 --- /dev/null +++ b/.Rprofile @@ -0,0 +1,11 @@ +library("devtools") +library("usethis") +library("testthat") + +styler::style_dir( + usethis::proj_get(), + style = styler::tidyverse_style, strict = TRUE, + exclude_files = "" +) + +# covr::report() diff --git a/.gitignore b/.gitignore index a50f6ff..73e458c 100644 --- a/.gitignore +++ b/.gitignore @@ -3,7 +3,6 @@ resources/ renv/ renv.lock docs -.Rprofile # History files .Rhistory diff --git a/R/ckd.R b/R/ckd.R index d699334..8a54c13 100644 --- a/R/ckd.R +++ b/R/ckd.R @@ -53,7 +53,7 @@ #' SCr = SCr_, SCysC = SCysC_, #' Age = Age_, height = height_, BUN = BUN_, #' male = male_, black = black_, pediatric = pediatric_ -#' )) +#' )) eGFR <- function(...) { UseMethod("eGFR") } @@ -232,7 +232,7 @@ eGFR.numeric <- function( #' 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") } @@ -304,8 +304,8 @@ eGFR_adult_SCr.numeric <- function(SCr, Age, male, black, ...) { #' #' eGFR_pt_data %>% #' dplyr::mutate(eGFR = eGFR_adult_SCysC( -#' SCysC = SCysC_,Age = Age_, male = male_ -#' )) +#' SCysC = SCysC_, Age = Age_, male = male_ +#' )) eGFR_adult_SCysC <- function(...) { UseMethod("eGFR_adult_SCysC") } @@ -378,7 +378,7 @@ eGFR_adult_SCysC.numeric <- function(SCysC, Age, male, ...) { #' 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") } @@ -453,7 +453,7 @@ eGFR_adult_SCr_SCysC.numeric <- function(SCr, SCysC, Age, male, black, ...) { #' eGFR_pt_data %>% #' dplyr::mutate(eGFR = eGFR_child_SCr( #' SCr = SCr_, height = height_, -#' )) +#' )) eGFR_child_SCr <- function(...) { UseMethod("eGFR_child_SCr") } @@ -516,7 +516,7 @@ eGFR_child_SCr.numeric <- function(SCr, height, ...) { #' 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") } @@ -577,7 +577,7 @@ eGFR_child_SCr_BUN.numeric <- function(SCr, height, BUN, ...) { #' eGFR_pt_data %>% #' dplyr::mutate(eGFR = eGFR_child_SCysC( #' SCysC = SCysC_ -#' )) +#' )) eGFR_child_SCysC <- function(...) { UseMethod("eGFR_child_SCysC") } @@ -807,8 +807,8 @@ Albuminuria_staging_AER.numeric <- function(AER, ...) { #' #' Albuminuria_staging_ACR(df, "ACR") #' -#'df %>% -#' dplyr::mutate(GFR_level = Albuminuria_staging_ACR(ACR)) +#' df %>% +#' dplyr::mutate(GFR_level = Albuminuria_staging_ACR(ACR)) Albuminuria_staging_ACR <- function(...) { UseMethod("Albuminuria_staging_ACR") } From a595b569d4a33c29150fcc48571ff11245eda096 Mon Sep 17 00:00:00 2001 From: alwinw <16846521+alwinw@users.noreply.github.com> Date: Sun, 6 Jun 2021 09:40:58 +1000 Subject: [PATCH 12/18] Updated utils and formatted examples --- NAMESPACE | 1 - R/aki.R | 1 - R/utils.R | 14 ++++++++++++-- man/Albuminuria_staging_ACR.Rd | 2 +- man/combine_date_time_cols.Rd | 9 ++++++++- man/combn_changes.Rd | 5 ++++- man/eGFR.Rd | 2 +- man/eGFR_adult_SCr.Rd | 2 +- man/eGFR_adult_SCr_SCysC.Rd | 2 +- man/eGFR_adult_SCysC.Rd | 4 ++-- man/eGFR_child_SCr.Rd | 2 +- man/eGFR_child_SCr_BUN.Rd | 2 +- man/eGFR_child_SCysC.Rd | 2 +- 13 files changed, 33 insertions(+), 15 deletions(-) diff --git a/NAMESPACE b/NAMESPACE index 6001a0e..7900c21 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -73,4 +73,3 @@ export(eGFR_child_SCr_BUN) export(eGFR_child_SCysC) importFrom(magrittr,"%>%") importFrom(rlang,.data) -importFrom(rlang,`:=`) diff --git a/R/aki.R b/R/aki.R index ac8896c..64b58f5 100644 --- a/R/aki.R +++ b/R/aki.R @@ -55,7 +55,6 @@ aki_stages <- factor( #' 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_staging <- function(...) { ellipsis::check_dots_used() diff --git a/R/utils.R b/R/utils.R index 498c7a5..b7b297f 100644 --- a/R/utils.R +++ b/R/utils.R @@ -209,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)), @@ -280,7 +287,10 @@ 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") } diff --git a/man/Albuminuria_staging_ACR.Rd b/man/Albuminuria_staging_ACR.Rd index f2b4a95..87671ff 100644 --- a/man/Albuminuria_staging_ACR.Rd +++ b/man/Albuminuria_staging_ACR.Rd @@ -48,5 +48,5 @@ df <- tibble::tibble( Albuminuria_staging_ACR(df, "ACR") df \%>\% - dplyr::mutate(GFR_level = Albuminuria_staging_ACR(ACR)) + dplyr::mutate(GFR_level = Albuminuria_staging_ACR(ACR)) } 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 ce0df67..8b5e950 100644 --- a/man/combn_changes.Rd +++ b/man/combn_changes.Rd @@ -34,5 +34,8 @@ of the same type provided (numeric or units) 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 07a0cf7..28248ae 100644 --- a/man/eGFR.Rd +++ b/man/eGFR.Rd @@ -111,5 +111,5 @@ eGFR_pt_data \%>\% 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 14167c9..c3a3212 100644 --- a/man/eGFR_adult_SCr.Rd +++ b/man/eGFR_adult_SCr.Rd @@ -52,5 +52,5 @@ eGFR_adult_SCr(eGFR_pt_data, 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 cf828e3..e6e7568 100644 --- a/man/eGFR_adult_SCr_SCysC.Rd +++ b/man/eGFR_adult_SCr_SCysC.Rd @@ -57,5 +57,5 @@ 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 6248af8..87b4b44 100644 --- a/man/eGFR_adult_SCysC.Rd +++ b/man/eGFR_adult_SCysC.Rd @@ -48,6 +48,6 @@ eGFR_adult_SCysC(eGFR_pt_data, eGFR_pt_data \%>\% dplyr::mutate(eGFR = eGFR_adult_SCysC( - SCysC = SCysC_,Age = Age_, male = male_ -)) + SCysC = SCysC_, Age = Age_, male = male_ + )) } diff --git a/man/eGFR_child_SCr.Rd b/man/eGFR_child_SCr.Rd index deaf819..3c79e82 100644 --- a/man/eGFR_child_SCr.Rd +++ b/man/eGFR_child_SCr.Rd @@ -46,5 +46,5 @@ eGFR_child_SCr(eGFR_pt_data, 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 2379e04..49221d4 100644 --- a/man/eGFR_child_SCr_BUN.Rd +++ b/man/eGFR_child_SCr_BUN.Rd @@ -49,5 +49,5 @@ eGFR_child_SCr_BUN(eGFR_pt_data, 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 14d5d54..7ac620b 100644 --- a/man/eGFR_child_SCysC.Rd +++ b/man/eGFR_child_SCysC.Rd @@ -43,5 +43,5 @@ eGFR_child_SCysC(eGFR_pt_data, eGFR_pt_data \%>\% dplyr::mutate(eGFR = eGFR_child_SCysC( SCysC = SCysC_ -)) + )) } From a561a7d4864b497ef40cb61a5e8b359c7281aff8 Mon Sep 17 00:00:00 2001 From: alwinw <16846521+alwinw@users.noreply.github.com> Date: Sun, 6 Jun 2021 09:43:18 +1000 Subject: [PATCH 13/18] Changed methods from .default to .data.frame --- NAMESPACE | 32 ++++++++++++++-------------- R/aki.R | 20 +++++++++--------- R/anemia.R | 2 +- R/ckd.R | 38 +++++++++++++++++----------------- R/utils.R | 2 +- man/Albuminuria_staging_ACR.Rd | 4 ++-- man/Albuminuria_staging_AER.Rd | 4 ++-- man/GFR_staging.Rd | 4 ++-- man/aki_SCr.Rd | 4 ++-- man/aki_UO.Rd | 4 ++-- man/aki_bCr.Rd | 4 ++-- man/aki_staging.Rd | 4 ++-- man/anemia.Rd | 4 ++-- man/combn_changes.Rd | 4 ++-- man/eGFR.Rd | 4 ++-- man/eGFR_adult_SCr.Rd | 4 ++-- man/eGFR_adult_SCr_SCysC.Rd | 4 ++-- man/eGFR_adult_SCysC.Rd | 4 ++-- man/eGFR_child_SCr.Rd | 4 ++-- man/eGFR_child_SCr_BUN.Rd | 4 ++-- man/eGFR_child_SCysC.Rd | 4 ++-- 21 files changed, 79 insertions(+), 79 deletions(-) diff --git a/NAMESPACE b/NAMESPACE index 7900c21..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_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(aki_staging,default) +S3method(aki_staging,data.frame) S3method(aki_staging,numeric) S3method(aki_staging,units) -S3method(anemia,default) +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("%>%") diff --git a/R/aki.R b/R/aki.R index 64b58f5..e705c2d 100644 --- a/R/aki.R +++ b/R/aki.R @@ -63,13 +63,13 @@ aki_staging <- function(...) { #' @rdname aki_staging #' @export -aki_staging.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))]] @@ -175,7 +175,7 @@ aki_bCr <- function(...) { #' @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))]], @@ -244,7 +244,7 @@ aki_SCr <- function(...) { #' @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))]], @@ -328,7 +328,7 @@ aki_UO <- function(...) { #' @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 3981173..1af972a 100644 --- a/R/anemia.R +++ b/R/anemia.R @@ -40,7 +40,7 @@ anemia <- function(...) { #' @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 8a54c13..7ab2599 100644 --- a/R/ckd.R +++ b/R/ckd.R @@ -87,16 +87,16 @@ 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() # [ ] !is.null won't work if SCr is a symbol... if (!is.null(SCr)) SCr <- .data[[rlang::as_name(rlang::enquo(SCr))]] @@ -239,7 +239,7 @@ eGFR_adult_SCr <- function(...) { #' @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))]], @@ -312,7 +312,7 @@ eGFR_adult_SCysC <- function(...) { #' @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))]], @@ -385,7 +385,7 @@ eGFR_adult_SCr_SCysC <- function(...) { #' @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))]], @@ -460,7 +460,7 @@ eGFR_child_SCr <- function(...) { #' @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))]], @@ -523,7 +523,7 @@ eGFR_child_SCr_BUN <- function(...) { #' @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))]], @@ -584,7 +584,7 @@ eGFR_child_SCysC <- function(...) { #' @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))]] @@ -661,7 +661,7 @@ GFR_staging <- function(...) { #' @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))]] ) @@ -752,7 +752,7 @@ Albuminuria_staging_AER <- function(...) { #' @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))]] ) @@ -815,7 +815,7 @@ Albuminuria_staging_ACR <- function(...) { #' @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/utils.R b/R/utils.R index b7b297f..ee5bd60 100644 --- a/R/utils.R +++ b/R/utils.R @@ -297,7 +297,7 @@ combn_changes <- function(...) { #' @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)) diff --git a/man/Albuminuria_staging_ACR.Rd b/man/Albuminuria_staging_ACR.Rd index 87671ff..26d3307 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, ...) diff --git a/man/Albuminuria_staging_AER.Rd b/man/Albuminuria_staging_AER.Rd index a920ddb..e41c528 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, ...) diff --git a/man/GFR_staging.Rd b/man/GFR_staging.Rd index db5be9d..feee850 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, ...) diff --git a/man/aki_SCr.Rd b/man/aki_SCr.Rd index e79e230..862e09c 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 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, ...) diff --git a/man/aki_UO.Rd b/man/aki_UO.Rd index 2beae37..98ef0c4 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} \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, ...) diff --git a/man/aki_bCr.Rd b/man/aki_bCr.Rd index 0e4df8a..968ee2a 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 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, ...) diff --git a/man/aki_staging.Rd b/man/aki_staging.Rd index 18248fb..4584e72 100644 --- a/man/aki_staging.Rd +++ b/man/aki_staging.Rd @@ -2,14 +2,14 @@ % Please edit documentation in R/aki.R \name{aki_staging} \alias{aki_staging} -\alias{aki_staging.default} +\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}{default}( +\method{aki_staging}{data.frame}( .data, SCr = NULL, bCr = NULL, diff --git a/man/anemia.Rd b/man/anemia.Rd index 743de6a..8f4370c 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, ...) diff --git a/man/combn_changes.Rd b/man/combn_changes.Rd index 8b5e950..a089630 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, ...) } diff --git a/man/eGFR.Rd b/man/eGFR.Rd index 28248ae..4ebd516 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, diff --git a/man/eGFR_adult_SCr.Rd b/man/eGFR_adult_SCr.Rd index c3a3212..dd0543c 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{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, ...) diff --git a/man/eGFR_adult_SCr_SCysC.Rd b/man/eGFR_adult_SCr_SCysC.Rd index e6e7568..d90104f 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{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, ...) diff --git a/man/eGFR_adult_SCysC.Rd b/man/eGFR_adult_SCysC.Rd index 87b4b44..a89a035 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{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, ...) diff --git a/man/eGFR_child_SCr.Rd b/man/eGFR_child_SCr.Rd index 3c79e82..4a6312c 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{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, ...) diff --git a/man/eGFR_child_SCr_BUN.Rd b/man/eGFR_child_SCr_BUN.Rd index 49221d4..2f2a7d7 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{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, ...) diff --git a/man/eGFR_child_SCysC.Rd b/man/eGFR_child_SCysC.Rd index 7ac620b..900cdbd 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{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, ...) From f8affbfc649771a3eeff6cb140734de953c02541 Mon Sep 17 00:00:00 2001 From: alwinw <16846521+alwinw@users.noreply.github.com> Date: Sun, 6 Jun 2021 09:57:13 +1000 Subject: [PATCH 14/18] Clarified param descriptions --- R/aki.R | 26 +++++++-------- R/anemia.R | 6 ++-- R/ckd.R | 58 +++++++++++++++++----------------- R/utils.R | 6 ++-- man/Albuminuria_staging_ACR.Rd | 2 +- man/Albuminuria_staging_AER.Rd | 2 +- man/GFR_staging.Rd | 2 +- man/aki_SCr.Rd | 6 ++-- man/aki_UO.Rd | 6 ++-- man/aki_bCr.Rd | 4 +-- man/aki_staging.Rd | 10 +++--- man/anemia.Rd | 6 ++-- man/combn_changes.Rd | 6 ++-- man/eGFR.Rd | 16 +++++----- man/eGFR_adult_SCr.Rd | 8 ++--- man/eGFR_adult_SCr_SCysC.Rd | 10 +++--- man/eGFR_adult_SCysC.Rd | 6 ++-- man/eGFR_child_SCr.Rd | 4 +-- man/eGFR_child_SCr_BUN.Rd | 6 ++-- man/eGFR_child_SCysC.Rd | 2 +- 20 files changed, 96 insertions(+), 96 deletions(-) diff --git a/R/aki.R b/R/aki.R index e705c2d..bf60d1a 100644 --- a/R/aki.R +++ b/R/aki.R @@ -38,15 +38,15 @@ aki_stages <- factor( #' #' @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 @@ -156,9 +156,9 @@ aki_staging.numeric <- function( #' #' @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 @@ -223,11 +223,11 @@ aki_bCr.numeric <- function(SCr, bCr, ...) { #' #' @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 @@ -307,11 +307,11 @@ aki_SCr.numeric <- function(SCr, dttm, pt_id, ...) { #' #' @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 diff --git a/R/anemia.R b/R/anemia.R index 1af972a..f0ddfad 100644 --- a/R/anemia.R +++ b/R/anemia.R @@ -18,11 +18,11 @@ #' #' @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 diff --git a/R/ckd.R b/R/ckd.R index 7ab2599..64738b8 100644 --- a/R/ckd.R +++ b/R/ckd.R @@ -20,21 +20,21 @@ #' #' @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) @@ -211,13 +211,13 @@ eGFR.numeric <- function( #' #' @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 @@ -286,11 +286,11 @@ eGFR_adult_SCr.numeric <- function(SCr, Age, male, black, ...) { #' #' @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 @@ -353,15 +353,15 @@ eGFR_adult_SCysC.numeric <- function(SCysC, Age, male, ...) { #' #' @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 @@ -436,9 +436,9 @@ eGFR_adult_SCr_SCysC.numeric <- function(SCr, SCysC, Age, male, black, ...) { #' #' @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 @@ -497,11 +497,11 @@ eGFR_child_SCr.numeric <- function(SCr, height, ...) { #' #' @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 @@ -562,7 +562,7 @@ eGFR_child_SCr_BUN.numeric <- function(SCr, height, BUN, ...) { #' #' @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 @@ -640,7 +640,7 @@ GFR_stages <- factor(c("G1", "G2", "G3a", "G3b", "G4", "G5"), ordered = TRUE) #' #' @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 @@ -731,7 +731,7 @@ Albuminuria_stages <- factor( #' #' @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 @@ -794,7 +794,7 @@ Albuminuria_staging_AER.numeric <- function(AER, ...) { #' #' @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 diff --git a/R/utils.R b/R/utils.R index ee5bd60..08f7053 100644 --- a/R/utils.R +++ b/R/utils.R @@ -275,11 +275,11 @@ combine_date_time_cols <- function(.data, tz = NULL) { #' #' @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 diff --git a/man/Albuminuria_staging_ACR.Rd b/man/Albuminuria_staging_ACR.Rd index 26d3307..1de7315 100644 --- a/man/Albuminuria_staging_ACR.Rd +++ b/man/Albuminuria_staging_ACR.Rd @@ -21,7 +21,7 @@ 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 diff --git a/man/Albuminuria_staging_AER.Rd b/man/Albuminuria_staging_AER.Rd index e41c528..3ea7070 100644 --- a/man/Albuminuria_staging_AER.Rd +++ b/man/Albuminuria_staging_AER.Rd @@ -21,7 +21,7 @@ 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 diff --git a/man/GFR_staging.Rd b/man/GFR_staging.Rd index feee850..4c6c431 100644 --- a/man/GFR_staging.Rd +++ b/man/GFR_staging.Rd @@ -21,7 +21,7 @@ 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 diff --git a/man/aki_SCr.Rd b/man/aki_SCr.Rd index 862e09c..b36e82e 100644 --- a/man/aki_SCr.Rd +++ b/man/aki_SCr.Rd @@ -21,13 +21,13 @@ 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 diff --git a/man/aki_UO.Rd b/man/aki_UO.Rd index 98ef0c4..20422cf 100644 --- a/man/aki_UO.Rd +++ b/man/aki_UO.Rd @@ -21,13 +21,13 @@ 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 diff --git a/man/aki_bCr.Rd b/man/aki_bCr.Rd index 968ee2a..be52bb4 100644 --- a/man/aki_bCr.Rd +++ b/man/aki_bCr.Rd @@ -21,10 +21,10 @@ 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 diff --git a/man/aki_staging.Rd b/man/aki_staging.Rd index 4584e72..ca68489 100644 --- a/man/aki_staging.Rd +++ b/man/aki_staging.Rd @@ -29,19 +29,19 @@ aki_staging(...) \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} \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} } \description{ Using KDIGO Clinical Practice Guideline for diff --git a/man/anemia.Rd b/man/anemia.Rd index 8f4370c..e0b3075 100644 --- a/man/anemia.Rd +++ b/man/anemia.Rd @@ -21,13 +21,13 @@ 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 diff --git a/man/combn_changes.Rd b/man/combn_changes.Rd index a089630..f4d2c7e 100644 --- a/man/combn_changes.Rd +++ b/man/combn_changes.Rd @@ -18,13 +18,13 @@ 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 diff --git a/man/eGFR.Rd b/man/eGFR.Rd index 4ebd516..cfff15b 100644 --- a/man/eGFR.Rd +++ b/man/eGFR.Rd @@ -52,28 +52,28 @@ 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) diff --git a/man/eGFR_adult_SCr.Rd b/man/eGFR_adult_SCr.Rd index dd0543c..0fd056c 100644 --- a/man/eGFR_adult_SCr.Rd +++ b/man/eGFR_adult_SCr.Rd @@ -21,16 +21,16 @@ 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 diff --git a/man/eGFR_adult_SCr_SCysC.Rd b/man/eGFR_adult_SCr_SCysC.Rd index d90104f..09fefde 100644 --- a/man/eGFR_adult_SCr_SCysC.Rd +++ b/man/eGFR_adult_SCr_SCysC.Rd @@ -21,19 +21,19 @@ 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 diff --git a/man/eGFR_adult_SCysC.Rd b/man/eGFR_adult_SCysC.Rd index a89a035..ee97aa3 100644 --- a/man/eGFR_adult_SCysC.Rd +++ b/man/eGFR_adult_SCysC.Rd @@ -21,13 +21,13 @@ 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 diff --git a/man/eGFR_child_SCr.Rd b/man/eGFR_child_SCr.Rd index 4a6312c..1fb638b 100644 --- a/man/eGFR_child_SCr.Rd +++ b/man/eGFR_child_SCr.Rd @@ -21,10 +21,10 @@ 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 diff --git a/man/eGFR_child_SCr_BUN.Rd b/man/eGFR_child_SCr_BUN.Rd index 2f2a7d7..81e6222 100644 --- a/man/eGFR_child_SCr_BUN.Rd +++ b/man/eGFR_child_SCr_BUN.Rd @@ -21,13 +21,13 @@ 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 diff --git a/man/eGFR_child_SCysC.Rd b/man/eGFR_child_SCysC.Rd index 900cdbd..92741be 100644 --- a/man/eGFR_child_SCysC.Rd +++ b/man/eGFR_child_SCysC.Rd @@ -21,7 +21,7 @@ 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 From 32db0a644472855c70ec59c97eede733379aa21e Mon Sep 17 00:00:00 2001 From: alwinw <16846521+alwinw@users.noreply.github.com> Date: Sun, 6 Jun 2021 10:22:27 +1000 Subject: [PATCH 15/18] Fixed bug for case when n% 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))) >= @@ -333,9 +333,10 @@ 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(n > 1) %>% # prevent n < m error in combn dplyr::ungroup() %>% dplyr::mutate(n_1 = cumsum(dplyr::lag(.data$n, default = 0))) %>% dplyr::rowwise() %>% @@ -344,7 +345,7 @@ combn_changes.POSIXct <- function(dttm, val, pt_id, ...) { # [ ]: 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 } diff --git a/tests/testthat/test-ckd.R b/tests/testthat/test-ckd.R index dfddb25..6d16466 100644 --- a/tests/testthat/test-ckd.R +++ b/tests/testthat/test-ckd.R @@ -439,5 +439,3 @@ test_that("Albuminuria_staging_ACR()", { expect_identical(df_uvec, ep) expect_identical(df_nvec, ep) }) - -# TODO: change from x.default to x.data.frame 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) +}) From 57b9ac80ddde9ad125d0880f5792fe22d10c13b3 Mon Sep 17 00:00:00 2001 From: alwinw <16846521+alwinw@users.noreply.github.com> Date: Sun, 6 Jun 2021 10:26:44 +1000 Subject: [PATCH 16/18] Cleaned up R comments --- R/hep-c.R | 2 +- R/utils.R | 4 ++-- tests/testthat/test-aki.R | 2 +- tests/testthat/test-ckd.R | 6 ------ tests/testthat/test-utils.R | 2 +- 5 files changed, 5 insertions(+), 11 deletions(-) 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/utils.R b/R/utils.R index 8eb89e1..cbf5a20 100644 --- a/R/utils.R +++ b/R/utils.R @@ -83,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]] } @@ -336,7 +336,7 @@ combn_changes.POSIXct <- function(dttm, val, pt_id, ...) { data_n <- data_gr %>% dplyr::count() %>% - dplyr::filter(n > 1) %>% # prevent n < m error in combn + 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() %>% diff --git a/tests/testthat/test-aki.R b/tests/testthat/test-aki.R index c08cfb3..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( 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 16d4512..650d64b 100644 --- a/tests/testthat/test-utils.R +++ b/tests/testthat/test-utils.R @@ -269,7 +269,7 @@ changes_exp_df <- function(env = parent.frame()) { test_that("combn_changes for data.frame", { df <- combn_changes(changes_rand_df(), "dttm_", "SCr_", "pt_id_") - expect_equal(df, changes_exp_df()) + expect_identical(df, changes_exp_df()) df <- combn_changes(changes_rand_df(), dttm_, SCr_, pt_id_) expect_equal(df, changes_exp_df()) From bec69f0e8e2a481c859d1f27850d3804dda6d4f7 Mon Sep 17 00:00:00 2001 From: alwinw <16846521+alwinw@users.noreply.github.com> Date: Sun, 6 Jun 2021 10:41:10 +1000 Subject: [PATCH 17/18] Removed .Rprofile for CI/CD --- .Rprofile | 11 ----------- .gitignore | 1 + 2 files changed, 1 insertion(+), 11 deletions(-) delete mode 100644 .Rprofile diff --git a/.Rprofile b/.Rprofile deleted file mode 100644 index 5b2bfa0..0000000 --- a/.Rprofile +++ /dev/null @@ -1,11 +0,0 @@ -library("devtools") -library("usethis") -library("testthat") - -styler::style_dir( - usethis::proj_get(), - style = styler::tidyverse_style, strict = TRUE, - exclude_files = "" -) - -# covr::report() diff --git a/.gitignore b/.gitignore index 73e458c..a50f6ff 100644 --- a/.gitignore +++ b/.gitignore @@ -3,6 +3,7 @@ resources/ renv/ renv.lock docs +.Rprofile # History files .Rhistory From 14512f7a702a53087106c8fdce13a3dd290ccbba Mon Sep 17 00:00:00 2001 From: alwinw <16846521+alwinw@users.noreply.github.com> Date: Sun, 6 Jun 2021 10:46:37 +1000 Subject: [PATCH 18/18] Fixed bug from testing expect_identical() --- tests/testthat/test-utils.R | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/testthat/test-utils.R b/tests/testthat/test-utils.R index 650d64b..16d4512 100644 --- a/tests/testthat/test-utils.R +++ b/tests/testthat/test-utils.R @@ -269,7 +269,7 @@ changes_exp_df <- function(env = parent.frame()) { test_that("combn_changes for data.frame", { df <- combn_changes(changes_rand_df(), "dttm_", "SCr_", "pt_id_") - expect_identical(df, changes_exp_df()) + expect_equal(df, changes_exp_df()) df <- combn_changes(changes_rand_df(), dttm_, SCr_, pt_id_) expect_equal(df, changes_exp_df())