From 672446c9275844a554b38b06bde69df9200a640d Mon Sep 17 00:00:00 2001 From: "Matthew L. Fidler" Date: Thu, 11 Jan 2024 10:12:26 -0600 Subject: [PATCH] Address some of Johns questions with a single accessor --- R/rxUiGet.R | 48 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 48 insertions(+) diff --git a/R/rxUiGet.R b/R/rxUiGet.R index 8393dae70..576df2b18 100644 --- a/R/rxUiGet.R +++ b/R/rxUiGet.R @@ -65,6 +65,54 @@ rxUiGet.stateDf <- function(x, ...) { } attr(rxUiGet.stateDf, "desc") <- "states and cmt number data.frame" +#' @export +#' @rdname rxUiGet +rxUiGet.params <- function(x, ...) { + .x <- x[[1]] + .ini <- .x$iniDf + .w <- !is.na(.ini$ntheta) & is.na(.ini$err) + .pop <- .ini$name[.w] + .w <- !is.na(.ini$ntheta) & !is.na(.ini$err) + .resid <- .ini$name[.w] + .w <- !is.na(.ini$neta1) + .cnds <- unique(.ini$condition[.w]) + .var <- lapply(.cnds, + function(cnd) { + .w <- which(.ini$condition == cnd & + .ini$neta1 == .ini$neta2) + .ini$name[.w] + }) + .mv <- rxGetModel(.x) + .lin <- FALSE + .doseExtra <- character(0) + .mv <- rxModelVars(.x) + if (!is.null(.x$.linCmtM)) { + .lin <- TRUE + if (.mv$extraCmt == 2L) { + .doseExtra <- c("depot", "central") + } else if (.mv$extramt == 1L) { + .doseExtra <- "central" + } + } + .predDf <- .x$predDf + if (!.lin & any(.predDf$linCmt)) { + .lin <- TRUE + if (.mv$flags["ka"] == 1L) { + .doseExtra <- c("depot", "central") + } else { + .doseExtra <- "central" + } + } + .dose <- c(.doseExtra, .x$state) + names(.var) <- .cnds + list(pop=.pop, + resid=.resid, + group=.var, + linCmt=.lin, + cmt=.dose) +} +attr(rxUiGet.params, "desc") <- "Parameter names" + #' @export #' @rdname rxUiGet rxUiGet.theta <- function(x, ...) {