Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix difftime bug for CRAN #178

Merged
merged 2 commits into from
Feb 6, 2025
Merged

Fix difftime bug for CRAN #178

merged 2 commits into from
Feb 6, 2025

Conversation

adamkucharski
Copy link
Member

A new change in r-devel affects how unique() behaves. Previously, calling unique() on a difftime object returned a numeric vector, but now it retains its difftime class.

Hence the following check in cfr_static, cfr_rolling and cfr_time_varying now fails:

identical(unique(diff(data$date)), 1)

because diff(data$date) returns a difftime object, and unique(diff(data$date)) no longer simplifies to numeric.

It has therefore been replaced with:

identical(unique(as.numeric(diff(data$date))), 1)

Once this PR is complete, we'll release version 0.13 onto CRAN with the above fix.

Previously, calling unique() on a difftime object returned a numeric vector, but now it retains its difftime class. Added as.numeric to fix bug in r-devel
@adamkucharski adamkucharski requested a review from Bisaloo February 6, 2025 10:56
Copy link
Member

@Bisaloo Bisaloo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can confirm the example issues are gone on R devel:

R.version
#>                _                                                 
#> platform       x86_64-pc-linux-gnu                               
#> arch           x86_64                                            
#> os             linux-gnu                                         
#> system         x86_64, linux-gnu                                 
#> status         Under development (unstable)                      
#> major          4                                                 
#> minor          5.0                                               
#> year           2025                                              
#> month          02                                                
#> day            02                                                
#> svn rev        87676                                             
#> language       R                                                 
#> version.string R Under development (unstable) (2025-02-02 r87676)
#> nickname       Unsuffered Consequences

Created on 2025-02-06 with reprex v2.1.1

@adamkucharski adamkucharski merged commit 4176a4a into main Feb 6, 2025
7 checks passed
@adamkucharski adamkucharski deleted the fix-difftime-class branch February 6, 2025 13:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants