Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

coercion-time-difference

Time difference coercion


Description

Coercion functions for creating difftime objects from other existing objects.

Usage

as.difftime(tim, ...)

## Default S3 method:
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.

Value

A difftime object with an attribute indicating the units.

Methods

See the following help topics for more details about individual methods:

generics

Examples

as.difftime(1:5, units = "secs")

as.difftime(c("01:55:22", "01:55:25"))

as.difftime("01", format = "%H")
as.difftime("01", format = "%H", units = "secs")

generics

Common S3 Generics not Provided by Base R Methods Related to Model Fitting

v0.1.0
MIT + file LICENSE
Authors
Hadley Wickham [aut, cre], Max Kuhn [aut], Davis Vaughan [aut], RStudio [cph]
Initial release

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.