Skip to content

Conversation

@d-morrison
Copy link

re: #902

I'm trying to preserve the Duration class through sum(); for example:

Before:

x = lubridate::duration(1:2)
sum(x)
#> [1] 3

After:

x = lubridate::duration(1:2)
sum(x)
#> [1] "3s"
class(x)
#> [1] "Duration"
#> attr(,"package")
#> [1] "lubridate"

Created on 2025-01-15 with reprex v2.1.1

Not sure if this will be helpful, but figured it was worth trying; glad to keep working on a better solution based on your feedback.
I used purrr::reduce(), which I'm guessing introduces an unwanted dependency.
I tried base::Reduce() but it doesn't preserves the Duration class unfortunately.

@vspinu
Copy link
Member

vspinu commented Apr 1, 2025

This is really nice addition but I would prefer to avoid adding extra dependency just for this change. It's straightforward to do in plain R.

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