tidyverse / lubridate

Make working with dates in R just that little bit easier
https://lubridate.tidyverse.org
GNU General Public License v3.0
724 stars 207 forks source link

unique() always zero for periods #1154

Open robchallen opened 6 months ago

robchallen commented 6 months ago

unique() for periods always returns zero. I'd expect it to either work or throw an error if not implemented. Workaround exists as below. Hope useful. Many thanks.

test = c(rep(lubridate::as.period("2 day"),3), rep(lubridate::as.period("1 day"),3))

# Undesirable behaviour:
if (unique(test)==0) warning("This is unexpected")

# Workaround
lubridate::as.period(unique(as.character(test)))
robchallen commented 6 months ago

lubridate_1.9.3