Coercion functions for creating difftime
objects from other
existing objects.
Usage
as.difftime(tim, ...)
# S3 method for default
as.difftime(tim, format = "%X", units = "auto", ...)
Arguments
- tim
A vector specifying a time interval.
- ...
Other arguments passed on to methods.
- format
A single character specifying the format of
tim
when it is a character. The default is a locale-specific time format.- units
A single character specifying units in which the results are desired. Required if
tim
is a numeric.
Details
This function overrides the non-generic as.difftime()
function
provided in base so that packages can provide methods for different data
types. The default method call the base version.
Methods
See the following help topics for more details about individual methods:generics
coercion-time-difference
:default
Examples
as.difftime(1:5, units = "secs")
#> Time differences in secs
#> [1] 1 2 3 4 5
as.difftime(c("01:55:22", "01:55:25"))
#> Time differences in hours
#> [1] 1.922778 1.923611
as.difftime("01", format = "%H")
#> Time difference of 1 hours
as.difftime("01", format = "%H", units = "secs")
#> Time difference of 3600 secs