Return Various Periods from a Time or Date Object
Creates an ordered factor from a vector of dates according to various
weekdays(x, abbreviate = TRUE)
months(x, abbreviate = TRUE)
quarters(x, abbreviate = TRUE)
a dates object.
a logical flag. If TRUE, abbreviations should be returned for
days of the week, month names, or quarters. Default is TRUE.
- The levels of days are the days of the month,
1 through 31.
- The levels of weekdays are Sunday through Saturday.
- The levels of months are January through December.
- The levels of quarters are I < II < III < IV
if abb=F and 1Q < 2Q < 3Q < 4Q if abbreviate=T.
- The levels of years are exactly the years of the dates
in x. Years in the range of x
that are not in x itself are not interpolated.
These functions are generic.
The default method works on dates objects
and other objects that can be coerced to dates objects.
There are also methods for timeDate, which take weekday and month names
and abbreviations from timeDateOptions(c("time.day.name",
"time.day.abb", "time.month.name", "time.month.abb")).
returns an ordered factor corresponding to days, weekdays, months,
quarters, or years of x for the respective function.
## Creates a sample dates object of julian dates
x <- c(10, 11, 12, 42, 44, 45, 101, 102, 212, 213, 214, 300)
dts <- as.Date(x, origin="1960-1-1")
## Alternatively, create a sample timeDate object
dts <- as(x, "timeDate")
## identifies a weekday or month with each julian day
## Produces barplot of # of days in x appearing on particular
## weekday or month
## Produces boxplots of julian date by weekday or month
# plot(weekdays(dts), x)
# plot(months(dts), x)