Description Usage Arguments Details Value See Also Examples
Method for cut
applied to date-time objects.
1 2 3 4 5 6 7 |
x |
an object inheriting from class |
breaks |
a vector of cut points or number giving the number of
intervals which |
labels |
labels for the levels of the resulting category. By default,
labels are constructed from the left-hand end of the intervals
(which are included for the default value of |
start.on.monday |
logical. If |
right, ... |
arguments to be passed to or from other methods. |
Note that the default for right
differs from the
default method. Using include.lowest =
TRUE
will include both ends of the range of dates.
Using breaks = "quarter"
will create intervals of 3 calendar
months, with the intervals beginning on January 1, April 1,
July 1 or October 1 (based upon min(x)
) as appropriate.
A vector of breaks
will be sorted before use: labels
should
correspond to the sorted vector.
A factor is returned, unless labels = FALSE
which returns
the integer level codes.
Values which fall outside the range of breaks
are coded as
NA
, as are and NA
values.
1 2 3 4 5 6 7 8 9 10 | ## random dates in a 10-week period
cut(ISOdate(2001, 1, 1) + 70*86400*stats::runif(100), "weeks")
cut(as.Date("2001/1/1") + 70*stats::runif(100), "weeks")
# The standards all have midnight as the start of the day, but some
# people incorrectly interpret it at the end of the previous day ...
tm <- seq(as.POSIXct("2012-06-01 06:00"), by = "6 hours", length.out = 24)
aggregate(1:24, list(day = cut(tm, "days")), mean)
# and a version with midnight included in the previous day:
aggregate(1:24, list(day = cut(tm, "days", right = TRUE)), mean)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.