Refactor combine_data function in transformations.R into smaller, manageable components #58
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.
Summary
This PR addresses the issue of the extremely long and complex
combine_datafunction intransformations.Rby breaking it down into smaller, more manageable helper functions.Changes Made
Main Achievement:
combine_datafunction from 355+ lines to 32 lines (91% reduction)Helper Functions Created:
.combine_data_validate_inputs()- Handles input validation and transformation setup.combine_data_prepare_data()- Manages data frame preparation and column handling.combine_data_validate_and_setup()- Performs data validation and output structure setup.combine_data_handle_unstandardized()- Special handling for unstandardized effect sizes (y).combine_data_calculations()- Handles OR→logOR transformation, standard errors, sample sizes, and t-statistics calculations.combine_data_transform()- Manages effect size transformations by type (d, z, r, logOR, OR).combine_data_create_output()- Creates final output with proper attributesBefore and After
Before: One monolithic 355+ line function handling all logic
After: Clean, readable coordinator function
Testing
This refactoring significantly improves code maintainability and readability while ensuring complete backward compatibility.
Fixes #56.
💬 Share your feedback on Copilot coding agent for the chance to win a $200 gift card! Click here to start the survey.