Add forceEncode option for regex-based option encoding#68
Merged
vandenman merged 6 commits intojasp-stats:masterfrom Jan 30, 2026
Merged
Add forceEncode option for regex-based option encoding#68vandenman merged 6 commits intojasp-stats:masterfrom
vandenman merged 6 commits intojasp-stats:masterfrom
Conversation
Introduces a forceEncode argument to encodeOptionsAndDataset and related functions, allowing specified option names (e.g., 'model') to have column names replaced via word-boundary-aware regex. Updates documentation and test cases to cover this feature, ensuring only specified options are affected and partial matches are avoided.
Contributor
There was a problem hiding this comment.
Pull request overview
This PR introduces a forceEncode parameter to the encoding workflow, enabling regex-based variable name replacement in options that contain embedded column names (like formula strings) but lack corresponding .types metadata. The feature is implemented across the encoding, test generation, and documentation layers.
Changes:
- Adds
forceEncodeparameter toencodeOptionsAndDataset()and related functions to enable regex-based column name replacement using word-boundary-aware patterns - Implements
forceEncodeValue()helper function that uses negative lookahead/lookbehind regex to replace variable names while avoiding partial matches - Updates test generator functions to propagate
forceEncodethrough the call chain and include it in generated test code - Adds comprehensive test cases covering basic usage, multiple options, word boundary handling, and selective application
Reviewed changes
Copilot reviewed 9 out of 10 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
| R/dataset.R | Adds forceEncode parameter to encodeOptionsAndDataset() and encodeOptionsWithMap(), implements forceEncodeValue() with regex-based replacement logic |
| R/test-generator.R | Propagates forceEncode through makeTestsFromExamples(), makeTestsFromSingleJASPFile(), and test block generators, updates generated test code to include forceEncode when specified |
| tests/testthat/test-encodeOptionsAndDataset.R | Adds four test cases covering basic regex encoding, selective option encoding, multiple options, and word boundary handling |
| man/*.Rd | Updates documentation for all modified functions to document the new forceEncode parameter |
Updated the flattenRecursive function in fixOptionsForVariableTypes to preserve user-facing fields (such as 'model' and 'modelOriginal') alongside the flattened value, while excluding internal JASP metadata fields. This ensures that relevant user data is not lost during the flattening process.
Added logic to re-encode the 'model' field from 'modelOriginal' when both are present in options, ensuring consistent encoding with our scheme rather than JASP's. Updated tests to verify correct re-encoding and preservation of the original modelOriginal field.
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
vandenman
approved these changes
Jan 30, 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.
Introduces a forceEncode argument to encodeOptionsAndDataset and related functions, allowing specified option names (e.g., 'model') to have column names replaced via word-boundary-aware regex. Updates documentation and test cases to cover this feature, ensuring only specified options are affected and partial matches are avoided.
AND
Added logic to re-encode the 'model' field from 'modelOriginal' when both are present in options, ensuring consistent encoding with our scheme rather than JASP's. Updated tests to verify correct re-encoding and preservation of the original modelOriginal field.