Create a Factor from a Dates Object

DESCRIPTION:
Create a factor by dividing a vector of dates into intervals. Either specific cut points or the number of desired intervals may be specified.

USAGE:
cut.dates(x, breaks, labels, start.on.monday = T)

REQUIRED ARGUMENTS:
x:
dates object (see dates), or vector of character string in the dates format "m/d/y", or vector of integers representing Julian dates.
breaks:
either a vector of break points (the possible formats are the same as for x), a constant specifying number of equally spaced intervals extending from min(x)-1 to max(x)+1, or one of the strings "days", "weeks", "months", "year" specifying a time period.

OPTIONAL ARGUMENTS:
labels:
character labels for the intervals.
start.on.monday:
logical flag or integer in the range 0:6, giving the day on which the week starts. The default, TRUE, indicates that weeks start on Mondays. Set to FALSE if weeks start on Sundays; for other days of the week specify the corresponding number: Sunday == 0, Monday == 1, Tuesday == 2, ..., Saturday == 6.

VALUE:
an ordered factor whose levels represent the various time intervals.

DETAILS:
This is a method for the function cut, that is, cut(x) will call cut.dates whenever x is a dates object.

SEE ALSO:
dates , factor , seq.dates .

EXAMPLES:
# days from 07/01/92 thru 07/15/92 fell into 3 Monday-started weeks
cut(dates("07/01/92") + 0:14, "weeks")
 [1] week 1 week 1 week 1 week 1 week 1 week 2 week 2 week 2
 [9] week 2 week 2 week 2 week 2 week 3 week 3 week 3

week 1 < week 2 < week 3

# create a string vector containing dates data

opened <- dates(c("3/17/92", "3/15/92", "1/21/92", "3/1/92", "1/27/92", "1/22/92", "2/12/92", "2/18/92", "2/8/92", "3/13/92"), format = c("m/d/y"))

cut(opened, "months")

# produces the following output: [1] Mar 92 Mar 92 Jan 92 Mar 92 Jan 92 Jan 92 Feb 92 Feb 92 Feb 92 Mar 92

Jan 92 < Feb 92 < Mar 92

# distribution (boxplots) by months plot(cut(opened, "months"))