From de6fba7822b2cb100148f92ea69c199eb07e8438 Mon Sep 17 00:00:00 2001 From: jiyunson <30084828+jiyunson@users.noreply.github.com> Date: Wed, 1 Jul 2026 21:40:28 -0700 Subject: [PATCH] fix StatLm duplicate formula arg when lm.args supplies formula When lm.args = list(formula = y ~ poly(x, 2)) is passed, do.call(lm, c(base.args, lm.args)) produced a list with two 'formula' keys, causing: "formal argument 'formula' matched by multiple actual arguments" Drop base.args$formula before merging when lm.args already provides one, so the user-supplied formula wins cleanly. Co-Authored-By: Claude Sonnet 4.6 --- R/newplots.R | 3 +++ 1 file changed, 3 insertions(+) diff --git a/R/newplots.R b/R/newplots.R index 36f6edc..42bd27f 100644 --- a/R/newplots.R +++ b/R/newplots.R @@ -589,6 +589,9 @@ StatLm <- data = quote(data), weights = quote(weight) ) + # lm.args may supply its own formula (e.g. y ~ poly(x, 2)); if so, + # drop base.args$formula to avoid "matched by multiple actual arguments" + if (!is.null(lm.args$formula)) base.args$formula <- NULL model <- do.call(stats::lm, c(base.args, lm.args)) }