The error occurs with days(1.5) , which does not allow fractional periods. You can do:
dt - days(1) - hours(12)
or
dt - 1.5*24*3600
or maybe there is a base date function that guys like @DirkEddelbuettel know about. Ah, this is difftime (I do not work with dates to remember these things from my head).
dt - as.difftime(1.5, units="days")
And as @maximusdooku pointed out:
dt - ddays(1.5)
(Based on the code, it looks like ddays just returns the number of seconds in the requested time period, as well as some class information.)
source share