days | R Documentation |
Creates an ordered factor from a vector of dates according to various calendar periods.
days(x)
weekdays(x, abbreviate = TRUE)
months(x, abbreviate = TRUE)
quarters(x, abbreviate = TRUE)
years(x)
x |
a |
abbreviate |
a logical flag. If |
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.
as.Date
, julian
,
timeDate
, hours
, yeardays
,
hms
## 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
weekdays(dts)
months(dts)
## Produces barplot of # of days in x appearing on particular
## weekday or month
plot(weekdays(dts))
plot(months(dts))
## Produces boxplots of julian date by weekday or month
plot(weekdays(dts), x)
plot(months(dts), x)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.