trunc.POSIXt: Return the floor, ceiling, or rounded value of date or time...

Description Usage Arguments Value Author(s) See Also Examples

Description

truncPOSIXt returns the date truncated to the specified unit. ceil.POSIXt returns next ceiling of the date at the unit selected in units. roundPOSIXt returns the date or time value rounded to nearest specified unit selected in digits.

truncPOSIXt and roundPOSIXt have been extended from the base package functions trunc.POSIXt and round.POSIXt which in the future will add the other time units we need.

Usage

1
2
3
4
5
6
7
8
9
ceil(x, units,...)
## Default S3 method:
ceil(x, units, ...)
truncPOSIXt(x, units = c("secs", "mins", "hours", "days",
"months", "years"), ...)
## S3 method for class 'POSIXt'
ceil(x, units = c("secs", "mins", "hours", "days",
"months", "years"), ...)
roundPOSIXt(x, digits = c("secs", "mins", "hours", "days", "months", "years"))

Arguments

x

date to be ceilinged, truncated, or rounded

units

unit to that is is rounded up or down to.

digits

same as units but different name to be compatible with round generic.

...

further arguments to be passed to or from other methods.

Value

An object of class POSIXlt.

Author(s)

Charles Dupont

See Also

Date POSIXt POSIXlt DateTimeClasses

Examples

1
2
3
4
date <- ISOdate(1832, 7, 12)
ceil(date, units='months')  # '1832-8-1'
truncPOSIXt(date, units='years')     # '1832-1-1'
roundPOSIXt(date, digits='months')    # '1832-7-1'

harrelfe/Hmisc documentation built on Oct. 3, 2019, 9:34 p.m.