| round | R Documentation |
Rounds and truncates objects of class 'timeDate'.
## S3 method for class 'timeDate'
round(x, digits = c("days", "hours", "mins", "secs", "months", "years"))
## S3 method for class 'timeDate'
trunc(x, units = c("days", "hours", "mins", "secs", "months", "years"),
...)
digits, units |
a character string denoting the date/time units in which the results are desired. |
x |
an object of class |
... |
arguments passed to other methods. |
The two functions round and trunc allow to round or to
truncate "timeDate" objects to the specified unit and return
them as "timeDate" objects.
There is an inconsistency in that round uses digits as
argument and not units.
From ‘timeDate’ version > 4041.110, the units of
rounding are the same as those for round.POSIXt and
trunc.POSIXt. Note though that the default for the
‘timeDate’ methods is "days", not "secs".
an object of class "timeDate"
timeFirstDayInMonth,
timeLastDayInMonth,
timeFirstDayInQuarter,
timeLastDayInQuarter,
timeNthNdayInMonth,
timeLastNdayInMonth,
timeNdayOnOrAfter,
timeNdayOnOrBefore
# create a timeDate object
dts <- c("1989-09-28", "2001-01-15", "2004-08-30", "1990-02-09")
tms <- c( "23:12:55.13", "10:34:02.23", "08:30:00.33", "11:18:23.53")
td <- timeDate(paste(dts, tms), format = "%Y-%m-%d %H:%M:%S",
zone = "GMT", FinCenter = "GMT")
## round
round(td) # same as round(td, "days")
round(td, "secs")
round(td, "mins")
round(td, "hours")
round(td, "days")
round(td, "months")
round(td, "years")
## truncate
trunc(td) # same as trunc(td, "days")
trunc(td, "secs")
trunc(td, "mins")
trunc(td, "hours")
trunc(td, "days")
trunc(td, "months")
trunc(td, "years")
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.