AsDate <- function(x) {
as.Date(x,
origin = "1970-01-01")
}
DaysOfYear <- function(date) {
startDate <- ymd(paste0(year(date), "0101"))
as.integer(date - startDate) + 1
}
IsRegularWeekend <- function(date) Weekdays(date) %in% c(6, 7)
Weekdays <- function(date) {
lubridate::wday(x = date,
week_start = 1)
}
DateSequence <- function(convention, from, to, by) {
base <- substring(by, nchar(by), nchar(by))
num <- as.integer(substring(by, 1, nchar(by) - 1))
addNum <- num
dateSeq <- from
tailElem <- from
ConvertTenorToDate <- SetTenorConverter(convention, from)
endDate <- ConvertTenorToDate(to)
while (tailElem < endDate) {
tailElem <- ConvertTenorToDate(paste0(num, base))
if (tailElem <= endDate) {
dateSeq <- c(dateSeq, tailElem)
}
num <- num + addNum
}
dateSeq
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.