I have an ifelse condition where I want to return a years value from package lubridate.
However, it does return 0 inside the ifelse and I have no idea why.
library(lubridate)
years(1)
[1] "1y 0m 0d 0H 0M 0S" # correct
years(2)
[1] "2y 0m 0d 0H 0M 0S" # correct
ifelse(1 == 1, years(1), years(2))
[1] 0 # wrong
Can anyone explain why the ifelse returns 0?