tidyverse / hms

A simple class for storing time-of-day values
https://hms.tidyverse.org/
Other
138 stars 25 forks source link

`unique()` returns an object of class numeric #97

Open joethorley opened 3 years ago

joethorley commented 3 years ago

Perhaps I'm missing something but it would be helpful if unique() returned an object of class hms

library(hms)
unique(hms::as_hms("10:01:01"))
#> [1] 36061

Created on 2021-03-08 by the reprex package (v1.0.0)

krlmlr commented 3 years ago

Thanks. We could implement this method (and basically all base methods implemented for the "vctrs_vctr" class).

We could also inherit from "vctrs_vctr" to get these for free; I'm not sure if this class supports this mode of operation, and we'd need to update a bunch of packages that assume that the class is c("hms", "difftime").

With so many "if-s", I'd prefer the first route for now. Would you like to take a stab?

joethorley commented 3 years ago

I'm happy to take a stab at the first route - expect a PR for unique.hms() by the end of the week and if that goes well more to follow.