Fix comma parsing in exclusion reasons for PRISMA flowdiagram data #3
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.
Problem
The PRISMA2020 package was failing to correctly parse inclusion/exclusion reasons that contained commas. This is a common real-world scenario where researchers write reasons like:
"Study design, wrong methodology, 15""Population too young, incorrect age range, 20""Wrong outcome, not relevant to review, 8"The expected format is
"Reason text, Count"where items are separated by semicolons:"Reason1, n1; Reason2, n2; Reason3, n3".Root Cause
The previous implementation used
gsub(",.*$", "", ...)to extract the reason andgsub(".*,", "", ...)to extract the count, which splits on the first comma instead of the last comma. This caused any reason containing a comma to be truncated incorrectly:Before (Broken):
Solution
Added a helper function
split_reason_n()inside thePRISMA_data()function that uses regex to split on the last comma only:^(.*),\s*([^,]+)$After (Fixed):
Changes
R/PRISMA_flowdiagram.Ronlydatabase_specific_resultsregister_specific_resultsdbr_excludedother_excludedBackward Compatibility
✅ No breaking changes
Testing
All tests pass including:
Examples
Simple case:
Complex case:
This fix enables users to write more natural, descriptive exclusion reasons without worrying about comma placement.
Warning
Firewall rules blocked me from connecting to one or more addresses (expand for details)
I tried to connect to the following addresses, but was blocked by firewall rules:
cloud.r-project.org/usr/lib/R/bin/exec/R -e install.packages(c('scales',~+~'stringr'),~+~repos='REDACTED',~+~lib='/tmp/Rlib')(dns block)cran.rstudio.com/usr/lib/R/bin/exec/R -e install.packages(c('scales',~+~'stringr'),~+~repos='REDACTED',~+~lib='/tmp/Rlib')(dns block)esm.ubuntu.com/usr/lib/apt/methods/https(dns block)If you need me to access, download, or install something from one of these locations, you can either:
Original prompt
This pull request was created as a result of the following prompt from Copilot chat.
✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.