TimeDateSubsets {fCalendar} | R Documentation |
A collection and description of functions and methods
for subsetting 'timeDate' objects.
Functions for testing 'timeDate' objects:
isWeekday | Tests if a date is a weekday or not, |
isWeekend | Tests if a date falls on a weekend or not, |
isBizday | Tests if a date is a business day or not, |
isHoliday | Tests if a date is a non-business day or not. |
Functions for getting additional information on 'timeDate' objects:
getDayOfWeek | Returns the day of the week to a 'timeDate' object, |
getDayOfYear | Returns the day of the year to a 'timeDate' object. |
Functions to extract subsets from 'timeDate' objects:
[.timeDate | Extracts or replaces subsets from 'timeDate' objects, |
cut.timeDate | Extracts a piece from a 'timeDate' object, |
start.timeDate | Extracts the first entry of a 'timeDate' object, |
end.timeDate | Extracts the last entry of a 'timeDate' object, |
length.timeDate | Gets the length of a 'timeDate' object, |
blockStart | Creates start dates for equally sized blocks, |
blockEnd | Creates end dates for equally sized blocks. |
isWeekday(x) isWeekend(x) isBizday(x, holidays = holidayNYSE()) isHoliday(x, holidays = holidayNYSE()) getDayOfWeek(x) getDayOfYear(x) ## S3 method for class 'timeDate': x[..., drop = TRUE] ## S3 method for class 'timeDate': cut(x, from , to, ...) ## S3 method for class 'timeDate': start(x, ...) ## S3 method for class 'timeDate': end(x, ...) ## S3 method for class 'timeDate': length(x) blockStart(x, block = 20) blockEnd(x, block = 20)
block |
an integer value specifying the length in number of records for numerically sized blocks of dates. |
drop |
["["] - a logical flag, by default TRUE .
|
from, to |
starting date, required, and end date, ptional. If supplied
to must be after from .
|
holidays |
[isBizday] - holiday dates from a holiday calendar. An object of class timeDate .
|
method |
[modify] - a character string defining the modification method, one of "sort" , "round" , or "trunc" .
|
x |
[isWeekday][isWeekend][isBizday][weekDay] - an object of class timeDate .
[format][print] - an object of class timeDate .
|
... |
arguments passed to other methods. |
isWeekday
isWeekend
isBizday
isHoliday
the functions return logical vectors indicating if a date is a
weekday, a weekend day, a business day, or a holiday. Note for
business and holidays extraction an holiday/business calendar
has to be specified.
getDayOfWeek
getDayOfYear
the function getDayOfWeek
returns a three letter character
string with the names of the day of the week, and the function
getDayOfWeek
returns the day count as integer value starting
January, 1st.
[.timeDate
cut.timeDate
start.timeDate
end.timeDate
blockStart
blockEnd
these are functions for subsetting "timeDate"
objects.
The function [.timeDate
extracts or replaces subsets,
the function cut
extracts a piece,
the functions start
and end
extract the first and last
element,
the functions blockStart
and blockEnd
create vectors of
start and end values for equally sized blocks. All functions return an
object of class "timeDate"
.
Diethelm Wuertz for the Rmetrics R-port.
timeDateCoercion
, timeDateCoercion
,
timeDateMathOps
, timeDateSpecDates
We also recommend to inspect the help pages for the POSIX time and date
class, ?Dates
, and the help pages from the contributed R packages
chron
and date
.
## SOURCE("fCalendar.3B-TimeDateSubsets") ## Easter - currentYear ## Easter - Easter(currentYear) tS = timeSequence(from = Easter(currentYear)-7*24*3600, length.out = 8) tS ## Weekdays and Weekend Days: isWeekday(tS) isWeekend(tS) getDayOfWeek(tS) ## Business Days and Holidays: holidayNYSE() isBizday(tS, holidayNYSE()) isHoliday(tS, holidayNYSE()) ## [ - Subsetting: tS[c(1, 6:8)] tS[isBizday(tS)] tS[isHoliday(tS)] ## cut - GoodFriday(currentYear) EasterMonday(currentYear) cut(tS, from = GoodFriday(currentYear), to = EasterMonday(currentYear)) ## start | end - start(tS) end(tS)