Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100644 48 lines (45 sloc) 1.139 kb
71129d4 Hadley Wickham First parse at documentation from roxygen
authored
1 \name{round_date}
2 \alias{round_date}
3 \title{Rounding for date-times.}
e3649af Hadley Wickham Roxygen 2.2
authored
4 \usage{
5 round_date(x,
6 unit = c("second", "minute", "hour", "day", "week", "month", "year"))
71129d4 Hadley Wickham First parse at documentation from roxygen
authored
7 }
e3649af Hadley Wickham Roxygen 2.2
authored
8 \arguments{
9 \item{x}{a vector of date-time objects}
71129d4 Hadley Wickham First parse at documentation from roxygen
authored
10
e3649af Hadley Wickham Roxygen 2.2
authored
11 \item{unit}{a character string specifying the time unit
12 to be rounded to. Should be one of
13 "second","minute","hour","day", "week", "month", or
14 "year."}
15 }
16 \value{
17 x with the appropriate units rounded
18 }
19 \description{
dc15618 Hadley Wickham Change wrapping with new roxygen
authored
20 round_date takes a date-time object and rounds it to the
21 nearest integer value of the specified time unit. Users
22 can specify whether to round to the nearest second,
23 minute, hour, day, week, month, or year.
71129d4 Hadley Wickham First parse at documentation from roxygen
authored
24 }
e3649af Hadley Wickham Roxygen 2.2
authored
25 \examples{
26 x <- as.POSIXct("2009-08-03 12:01:59.23")
71129d4 Hadley Wickham First parse at documentation from roxygen
authored
27 round_date(x, "second")
28 # "2009-08-03 12:01:59 CDT"
29 round_date(x, "minute")
30 # "2009-08-03 12:02:00 CDT"
31 round_date(x, "hour")
32 # "2009-08-03 12:00:00 CDT"
33 round_date(x, "day")
34 # "2009-08-04 CDT"
35 round_date(x, "week")
36 # "2009-08-02 CDT"
37 round_date(x, "month")
38 # "2009-08-01 CDT"
39 round_date(x, "year")
e3649af Hadley Wickham Roxygen 2.2
authored
40 # "2010-01-01 CST"
41 }
42 \seealso{
43 \code{\link{floor_date}}, \code{\link{ceiling_date}}
44 }
45 \keyword{chron}
46 \keyword{manip}
47
Something went wrong with that request. Please try again.