tidyverts / tsibble

Tidy Temporal Data Frames and Tools
https://tsibble.tidyverts.org
GNU General Public License v3.0
528 stars 50 forks source link

max does not return maximum yearmonth from passed arguments #257

Closed Fuco1 closed 7 months ago

Fuco1 commented 3 years ago

Taking a max of two yearmonths, the smaller (earlier) is returned.

> max(yearmonth('2017-01-01'), yearmonth('2018-04-01'))
<yearmonth[1]>
[1] "2017 Jan"

However, taking a max of two date objects, the bigger (later) is correctly returned.

> max(as.Date('2017-01-01'), as.Date('2018-04-01'))
[1] "2018-04-01"
> 
mitchelloharawild commented 3 years ago

This is an inherited from the {vctrs} package, the relevant issue for this is here: https://github.com/r-lib/vctrs/issues/1372

Passed via

library(tsibble)
max(yearmonth('2017-01-01'), yearmonth('2018-04-01'))
#> <yearmonth[1]>
#> [1] "2017 Jan"

Passed via ..1 (x)

max(c(yearmonth('2017-01-01'), yearmonth('2018-04-01')))
#> <yearmonth[1]>
#> [1] "2018 Apr"

Created on 2021-05-26 by the reprex package (v2.0.0)

Fuco1 commented 3 years ago

I see. I suppose we can close this issue then, unless you want to use it as a soft pressure device for the upstream :D Thanks for the heads up!