fix StatLm duplicate formula arg when lm.args supplies formula#191
Open
jiyunson wants to merge 1 commit into
Open
fix StatLm duplicate formula arg when lm.args supplies formula#191jiyunson wants to merge 1 commit into
jiyunson wants to merge 1 commit into
Conversation
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 <noreply@anthropic.com>
|
Thanks. I'm traveling the next two weeks, and I may not get a chance to look at this until I return. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Hey Randall -- just a tiny edit! Thanks as always for all your awesome work on mosaic/ggformula/etc.
Summary
When
lm.args = list(formula = y ~ poly(x, 2))is passed togf_lm()orstat_lm(), the call todo.call(stats::lm, c(base.args, lm.args))fails with:because
base.argsalready containsformula = y ~ x(the default), andlm.argsadds a secondformulakey.The fix is one line: drop
base.args$formulabefore merging whenlm.argsalready provides its own formula, so the user-supplied formula wins cleanly.Reproduction
Note: the
formula = y ~ poly(x, 2)direct-param syntax already works; this fixes thelm.argspath to be consistent.Test plan
lm.args = list(formula = ...)no longer errorslm.args = list(formula = ...)produces the same fit asformula = ...directlylm.args = list()) is unchanged🤖 Generated with Claude Code