
Last chance! 50% off unlimited learning
Sale ends in
trunc.POSIXt
returns the date truncated to the specified unit.
ceiling.POSIXt
returns next ceiling of the date at the unit selected in
units
.
floor.POSIXt
trunk.POSIXt
by another name.
round.POSIXt
returns the date or time value rounded to nearest
specified unit selected in digits
. trunc.POSIXt
and round.POSIXt
have been extended from
the base
package functions.
ceil(x, units,...)
"ceil"(x, units, ...)
"trunc"(x, units = c("secs", "mins", "hours", "days",
"months", "years"), ...)
"ceil"(x, units = c("secs", "mins", "hours", "days",
"months", "years"), ...)
"round"(x, digits = c("secs", "mins", "hours", "days", "months", "years"))
units
but different name to be compatible
with round
generic.
POSIXlt
.
Date
POSIXt
POSIXlt
DateTimeClasses
date <- ISOdate(1832, 7, 12)
ceil(date, units='months') # '1832-8-1'
trunc(date, units='years') # '1832-1-1'
round.POSIXt(date, digits='months') # '1832-7-1'
Run the code above in your browser using DataLab