Merge lFormula/glFormula via shared mkFormula() helper#4
Open
Copilot wants to merge 7 commits into
Open
Conversation
… use it Co-authored-by: annahuynhly <97189987+annahuynhly@users.noreply.github.com>
Co-authored-by: annahuynhly <97189987+annahuynhly@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Merge lFormula() and glFormula() for cleanup
Merge lFormula/glFormula via shared mkFormula() helper
Mar 18, 2026
Owner
|
@copilot can you observe the issue above? I.e., the fact that The following code is also repeated (which I did not mention earlier): |
Agent-Logs-Url: https://github.com/annahuynhly/lme4/sessions/f5aac6ad-645c-4710-bbd5-c315ffef42c1 Co-authored-by: annahuynhly <97189987+annahuynhly@users.noreply.github.com>
Agent-Logs-Url: https://github.com/annahuynhly/lme4/sessions/f5aac6ad-645c-4710-bbd5-c315ffef42c1 Co-authored-by: annahuynhly <97189987+annahuynhly@users.noreply.github.com>
Agent-Logs-Url: https://github.com/annahuynhly/lme4/sessions/f5aac6ad-645c-4710-bbd5-c315ffef42c1 Co-authored-by: annahuynhly <97189987+annahuynhly@users.noreply.github.com>
Author
Done in 28e5651. I moved the shared |
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.
lFormula()andglFormula()shared ~90% identical implementation, noted by DRY/TODO comments in the code. This PR extracts the shared body into a privatemkFormula()helper, eliminating the duplication.Changes
New
mkFormula()internal helper — contains all shared logic: model-frame evaluation,reTrmsconstruction, identifiability checks,predvarsextraction, andXmatrix building/scaling. Behavioral differences are parameterized:allow.n—FALSEfor lmer,TRUEfor glmercheck_zero_rows— lmer-only "0 (non-NA) cases" guardcheck_na_Zt— lmer-only NA-in-Z checkset_varnames_fixed— lmer-onlyvarnames.fixedattributeAdditional cleanup from PR feedback — moved the remaining duplicated preprocessing from both public functions into
mkFormula():fr.form.andfr.formconstruction is now centralizedweights/offsetenvironment assignment loop is now centralizedmissing()-based argument detection behavior in caller framelFormula()— now keeps only lmer-specific setup (arg checking, family redirect,match.call()construction), delegates preprocessing/build steps tomkFormula(), appendsREMLglFormula()— now keeps only glmer-specific setup (family handling,mustart/etastartmodel-frame args), delegates preprocessing/build steps tomkFormula(), setsstartattribute onfrpost-call, appendsfamilyRemoved all
DRY!,TODO: merge, and## FIXME: does start= do anything?comments that prompted this changePublic signatures of both functions are unchanged.
Original prompt
✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.