From 9220a67387b6bc2f8551ebe9f2ecb8fe40c285b5 Mon Sep 17 00:00:00 2001 From: Marius Thomas Date: Tue, 13 Oct 2026 11:14:26 +0200 Subject: [PATCH 1/2] fix bug in plotMod --- R/fitMod_helpers.R | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/R/fitMod_helpers.R b/R/fitMod_helpers.R index 33891cb..fb72d56 100644 --- a/R/fitMod_helpers.R +++ b/R/fitMod_helpers.R @@ -453,7 +453,7 @@ plotFunc <- function(x, CI = FALSE, level = 0.95, if(plotData %in% c("means", "meansCI")){ ## produce estimates for ANOVA type model data$doseFac <- as.factor(data[[doseNam]]) - form <- as.formula(paste(respNam, "~ doseFac +", addCovars[2])) + form <- as.formula(paste0("`", respNam, "` ~ doseFac + ", deparse(addCovars[[2]]))) fit <- lm(form, data=data) ## build design matrix for prediction dose <- sort(unique(data[[doseNam]])) @@ -548,7 +548,7 @@ plotFunc <- function(x, CI = FALSE, level = 0.95, ylim <- c(rng[1] - 0.05 * dff, rng[2] + 0.05 * dff) ## produce plot - form <- as.formula(paste(respNam, "~", doseNam, "|model", sep="")) + form <- as.formula(paste0("`", respNam, "` ~ `", doseNam, "` | model")) print( lattice::xyplot(form, groups = plotdf$group, data = plotdf, pList=pList, ..., ylim = ylim, panel = function(x, y, ..., pList){ From 5bda95d8094295cff824da9f69d7ffacf8d521bf Mon Sep 17 00:00:00 2001 From: Marius Thomas Date: Tue, 13 Oct 2026 11:17:03 +0200 Subject: [PATCH 2/2] add test for plot.DRMod --- tests/testthat/test-fitMod.R | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/tests/testthat/test-fitMod.R b/tests/testthat/test-fitMod.R index 606f29c..0c54853 100644 --- a/tests/testthat/test-fitMod.R +++ b/tests/testthat/test-fitMod.R @@ -286,3 +286,16 @@ test_that("fitMod complains if `resp` is a row-vector", { type = "general", bnds = defBnds(max(doses))$emax), "resp_row is not a numeric but a matrix, converting with as.numeric()") }) + +test_that("plotting works when dose/resp are supplied as expressions", { + data(IBScovars) + anovaMod <- lm(resp~factor(dose)+gender, data=IBScovars) + drFit <- coef(anovaMod)[2:5] + vCov <- vcov(anovaMod)[2:5,2:5] + gfit <- fitMod(sort(unique(IBScovars$dose))[-1], drFit, S=vCov, model = "emax", + type = "general", placAdj = TRUE, bnds = c(0.01, 2)) + pdf(NULL) + on.exit(dev.off()) + expect_no_error(plot(gfit, CI=TRUE, plotData = "meansCI")) + expect_no_error(plot(gfit, CI=TRUE, plotData = "means")) +})