tidyverts / tsibble

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

Methods to compare year* with dates #267

Open arnaud-feldmann opened 2 years ago

arnaud-feldmann commented 2 years ago
yearmonth("2021 04")>date("2021/03/01")
#[1] TRUE
#Warning message:
#Incompatible methods (">.vctrs_vctr", ">.Date") for ">"
yearmonth("2021 04")>date("2021/04/01")
#[1] FALSE
#Warning message:
#Incompatible methods (">.vctrs_vctr", ">.Date") for ">"
yearmonth("2020 04")>date("2021/03/01")
#[1] FALSE
#Warning message:
#Incompatible methods (">.vctrs_vctr", ">.Date") for ">"
yearquarter("2021Q1")>date("2021/03/01")
 #[1] FALSE
#Warning message:
#Incompatible methods (">.vctrs_vctr", ">.Date") for ">" 
yearquarter("2021Q2")>date("2021/03/01")
#[1] TRUE
#Warning message:
#Incompatible methods (">.vctrs_vctr", ">.Date") for ">" 

It gives the right result but gives a warning.

It would be very fine for it to work without explicit conversions in order to be able to write generic functions that work on yearmonth, yearquarter.