diff --git a/R/confint.R b/R/confint.R index 3061beb4f..fd5356151 100644 --- a/R/confint.R +++ b/R/confint.R @@ -39,7 +39,7 @@ confint.rxSolve <- function(object, parm = NULL, level = 0.95, ...) { .useT <- TRUE if (any(names(.args) == "useT")) { .useT <- .args$useT - checkmate::assertLogical(useT, len=1, any.missing=FALSE, .var.name="pred") + checkmate::assertLogical(.useT, len=1, any.missing=FALSE, .var.name="useT") } if (any(names(.args) == "mean")) { .mean <- .args$mean diff --git a/tests/testthat/test-meanProb.R b/tests/testthat/test-meanProb.R index 247ea9dae..aa1ffc95a 100644 --- a/tests/testthat/test-meanProb.R +++ b/tests/testthat/test-meanProb.R @@ -89,4 +89,28 @@ test_that("test meanProb()", { expect_equal(ci1$eff, ci2$eff) + + ci1 <- confint(pk1, "blood", mean=TRUE, useT=FALSE) + + # use dplyr + ci2 <- pk1 |> + dplyr::group_by(time) |> + dplyr::reframe(eff=meanProbs(blood, c(0.025, 0.5, 0.975), na.rm=TRUE, names=FALSE, useT=FALSE), + p1=c(0.025, 0.5, 0.975), Percentile=c("2.5%", "50%", "97.5%")) |> + dplyr::arrange(time, p1) + + expect_equal(ci1$eff, ci2$eff) + + ci1 <- confint(pk1, "blood", mean=TRUE, useT=FALSE, pred=TRUE) + + # use dplyr + ci2 <- pk1 |> + dplyr::group_by(time) |> + dplyr::reframe(eff=meanProbs(blood, c(0.025, 0.5, 0.975), na.rm=TRUE, names=FALSE, useT=FALSE, + pred=TRUE), + p1=c(0.025, 0.5, 0.975), Percentile=c("2.5%", "50%", "97.5%")) |> + dplyr::arrange(time, p1) + + expect_equal(ci1$eff, ci2$eff) + })