new_duration
in a way that is more suitable
for automating within a function.duration(num = 0, units = "seconds")
Durations record the exact number of seconds in a time span. They measure the exact passage of time but do not always align with measurements made in larger units of time such as hours, months and years. This is because the length of larger time units can be affected by conventions such as leap years and Daylight Savings Time. Base R provides a second class for measuring durations, the difftime class.
Duration objects can be easily created with the helper
functions dweeks
, ddays
,
dminutes
, dseconds
. These
objects can be added to and subtracted to date- times to
create a user interface similar to object oriented
programming.
new_duration
, as.duration
duration(90, "seconds")
# 90s
duration(1.5, "minutes")
# 90s
duration(-1, "days")
# -86400s (~-1 days)
Run the code above in your browser using DataLab