Add POC helpers for NSE resolution and where subsetting#191
Merged
dbosak01 merged 2 commits intodbosak01:masterfrom Mar 18, 2026
Merged
Add POC helpers for NSE resolution and where subsetting#191dbosak01 merged 2 commits intodbosak01:masterfrom
dbosak01 merged 2 commits intodbosak01:masterfrom
Conversation
Owner
|
Wow! Looks great! Will review tomorrow. |
Owner
|
I like it, and am inclined to just merge it. Do you feel there are any risks? I can go back over some of the testing/validation this weekend. I'm going to do it anyway because I made a few changes this week. |
dbosak01
requested changes
Mar 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.
This PR is a proof of concept only and is not intended to be merged.
The goal is to get feedback on whether it makes sense to centralize two repeated internal patterns that appear across the package:
whereargumentFor this POC, I added two internal helpers in
R/utilities.R:resolve_arg()subset_data()I then updated the current repeated call sites in the affected procedures and plot helpers to use those functions.
What changed
resolve_arg()resolve_arg()is meant to replace the repeated pattern that currently does:The helper:
typeargument used by the helpersubset_data()subset_data()centralizeswherefiltering and adds explicit validation.The helper:
datato be adata.framewhereisNULLwhereto be anexpressionof length 1wherein the data environmentnrow(data)Files touched
Helpers:
R/utilities.RUpdated
resolve_arg()call sites:R/proc_freq.RR/proc_means.RR/proc_reg.RR/proc_sort.RR/proc_transpose.RR/proc_ttest.RR/freqplots.RR/regplots.RR/ttestplots.RUpdated
subset_data()call sites:R/proc_freq.RR/proc_means.RR/proc_reg.RR/proc_sort.RR/proc_transpose.RR/proc_ttest.RTests:
tests/testthat/test-utilities.RMain review points
The most useful feedback for this POC would be:
resolve_arg()preserves current quoted/unquoted behaviorsubset_data()works as expectedPlease test:
doubleorintegeris now allowedwhere = expression(...)flowswhereinputs and the resulting error messagesWe also need to consider the placement of the existing zero-row guard in functions that support subsetting through
where, since applying the subset may itself produce zero rows:If this check stays before
whereprocessing, it only validates the original input. If it needs to protect downstream logic after subsetting as well, it may need to be revisited in the affected procedures.Validation so far
I added direct unit coverage for both helpers in
tests/testthat/test-utilities.R.How to pull this branch locally for testing
These commands do not need to be run from the exact same local repo that I used.
They do need to be run from a local Git clone of the
procsrepository family, for example:dbosak01/procsprocsIn other words, the commands should be run from the root of your own local
procsrepo, not from an unrelated directory.https://github.com/ankonyeni/procs.gitpoc/nse-where-helpersOption 1: add my fork as a temporary remote
Option 2: one-off fetch without adding a remote
Cleanup after testing
If you want to remove the local testing branch afterward:
If you added my fork as a temporary remote, you can also remove it: