| round.POSIXlt {flux} | R Documentation |
Round times.
Description
There are round methods in base for objects of DateTimeClasses. However, they can only round to full second, minutes, hours, and days. These functions offer some more options.
Usage
## S3 method for class 'POSIXlt'
round(x, digits = c("mins", "5mins", "10mins", "15mins", "quarter hours",
"30mins", "half hours", "hours"))
## S3 method for class 'POSIXct'
round(x, ...)
Arguments
x |
A |
digits |
Either a character string specifying the time units to round to (see choices above) or a numeric specifying the minutes to round to. To go to seconds just use values < 1, to go beyond the hour just use values > 60. |
... |
Further arguments to methods. |
Value
A POSIXct object with rounded, not truncated date times.
Author(s)
Gerald Jurasinski, gerald.jurasinski@uni-rostock.de,
borrowing heavily from https://stat.ethz.ch/pipermail/r-help/2012-June/315336.html
Examples
# Current time in GMT and as class "POSIXlt"
zlt <- as.POSIXlt(Sys.time(), "GMT")
# Same time as class POSIXct
zct <- as.POSIXct(zlt)
# round to minute
round(zct)
# round to half hour
round(zct, "30mins")
round(zct, "half hour")
round(zct, 30)
# round to 20 minutes
round(zlt, 20)
# round to 30 seconds
round(zlt, 0.5)
[Package flux version 0.3-0.1 Index]