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

trunc.times

Truncate times Objects


Description

Truncate times objects.

Usage

## S3 method for class 'times'
trunc(x, units = "days", eps = 1e-10, ...)

Arguments

x

a "times" object.

units

Can be one of "days", "hours", "minutes", "seconds" or an unambiguous abbreviated version of any of those.

eps

Comparison tolerance. Times are considered equal if their absolute difference is less than eps.

...

further arguments to be passed to or from methods.

Details

The time is truncated to the second, minute, hour or day or to the value specified.

There is also a round method which has the same arguments as the trunc method, and performs rounding instead of truncation.

Value

An object of class "times".

See Also

trunc for the generic function and default methods.

Examples

tt <- times(c("12:13:14", "15:46:17"))
trunc(tt, "minutes")
trunc(tt, "min")
trunc(tt, times("00:01:00"))
trunc(tt, "00:01:00")
trunc(tt, 1/(24*60))

tt2 <- structure(c(3.0, 3.1, 3.5, 3.9), class = "times")
trunc(tt2, "day")
trunc(tt2)

chron

Chronological Objects which can Handle Dates and Times

v2.3-56
GPL-2
Authors
David James [aut] (S original), Kurt Hornik [aut, trl, cre] (<https://orcid.org/0000-0003-4198-9911>), Gabor Grothendieck [ctb], R Core Team [ctb]
Initial release

We don't support your browser anymore

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