powered by
Set units of difftime objects, with additional support of 'months' and 'years'.
'months'
'years'
units_difftime(x) <- value
Function units_difftime<- returns a difftime object.
difftime object
character scalar, choice of unit
Function units_difftime<- supports 'months' and 'years' in addition to 'secs', 'mins', 'hours', 'days', 'weeks' supported in function units<-.difftime.
'secs'
'mins'
'hours'
'days'
'weeks'
(x = Sys.Date() - as.Date('2021-01-01')) tryCatch(units(x) <- 'months', error = identity) units_difftime(x) <- 'months'; x units_difftime(x) <- 'years'; x
Run the code above in your browser using DataLab