Conversation
aloctavodia
approved these changes
Nov 15, 2026
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.
#626 removes a linear term that is also an argument of a smooth term, such as
xnext tos(x).parse_additive_terms()should reject a named argument ofs()ort2(), but its regex\(.+,.*=.+\)finds an=only after a comma. Thuss(by = g, x),s(k = 5, x),s(x = x1)andt2(k = 4, x, z)passed the check. Withy ~ x + g + s(by = g, x),smooth_covered_terms()then returnedxandg, and the projection removed the linear termg. A smooth term withby = gdoes not contain the main effect ofg.Changes
parse_additive_terms()parses each smooth term withstr2lang()and calls the new helperhas_named_smooth_arg(). The helper finds a named argument at any position in ans()ort2()call, also in a call inside it, such ass(poly(x, degree = 2)). The error message does not change. The PR adds a NEWS item.This follows the review suggestion on #626 to keep only the unnamed arguments in
smooth_args(). With only that filter,s(by = g, x)would pass the check, and the projection would keep the linear termx1next tos(x = x1). The new check rejects both, sosmooth_args()gets only unnamed arguments.As before this PR, smooth terms inside an interaction, such as
s(x, k = 5):z, go to the interaction terms and are not checked.Tests
test_formula.Rhas a new test block. It checks the error for 8 term forms, no error for 4 smooth terms without named arguments, andextract_terms_response()fory ~ x + g + s(by = g, x). With theR/formula.Rof master 6fef1de, 5 expectations fail: the 4 forms that passed the check, andextract_terms_response().Full suite with
NOT_CRAN=trueon Triton: 60,084 expectations, 0 failed, 5 skipped, 19 warnings (CHOLMOD, generalized Pareto, Pareto k). The same warnings occur on master. Versions: R 4.5.3, testthat 3.3.2, lme4 2.0.6, mgcv 1.9.4, gamm4 0.3.0, brms 2.23.1, rstanarm 2.32.2.This PR was assisted by Claude