Add nan parameter to fcoalesce for NaN/NA distinction control#7189
Merged
MichaelChirico merged 8 commits intomasterfrom Jul 21, 2025
Merged
Add nan parameter to fcoalesce for NaN/NA distinction control#7189MichaelChirico merged 8 commits intomasterfrom
MichaelChirico merged 8 commits intomasterfrom
Conversation
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## master #7189 +/- ##
=======================================
Coverage 98.77% 98.77%
=======================================
Files 81 81
Lines 15204 15215 +11
=======================================
+ Hits 15018 15029 +11
Misses 186 186 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
|
Generated via commit 2ce965f Download link for the artifact containing the test results: ↓ atime-results.zip
|
| } | ||
| \usage{ | ||
| fcoalesce(\dots) | ||
| fcoalesce(\dots, nan = NA) |
Member
There was a problem hiding this comment.
Suggested change
| fcoalesce(\dots, nan = NA) | |
| fcoalesce(\dots, nan=NA) |
MichaelChirico
approved these changes
Jul 21, 2025
Member
MichaelChirico
left a comment
There was a problem hiding this comment.
LGTM! Please add a NEWS entry
Member
|
sorry, last step is to merge master to resolve the conflict |
Contributor
Author
|
Done, sorry for the delay, my laptop's been quite slow but the merge is complete now. |
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.

fixes #4567
Currently fcoalesce always treats NaN as missing (same as NA_real_), providing no user control over NaN handling. This inconsistency with nafill, which offers a nan parameter for controlling whether NaN should be treated distinctly from NA.
This PR adds a nan parameter to fcoalesce with default behavior nan=NA (treating NaN as missing, default) and option nan=NaN (preserving NaN values), ensuring fcoalesce(x, y, nan=Z) behaves consistently with nafill(x, fill=y, nan=Z) when y is length-1.
Implemetation:
In
wraper.R- Added nan parameter with default behaviour -nan = NAmeans treatNaNasNA- in both fcoalesce as well setcoalesceThen update header -
data.table.hto match new function signature.In
coalesce.cnan_is_na_argto support user controlThe logic is :
nan_is_na(NA) -> TRUE - then use ISNAN(val) - thus both NaN and NA_real treated as missing
nan_is_na(NaN) -> FALSE - then use ISNA(val) - thus only NA_real treated as missing, NaN preserved
In Docs change -
coalesce.Rd:@MichaelChirico @jangorecki can you please review