X-Git-Url: https://git.auder.net/assets/current/gitweb.css?a=blobdiff_plain;f=old_C_code%2Fstage2_UNFINISHED%2Fsrc%2Funused%2F00_createCalendar.r;fp=old_C_code%2Fstage2_UNFINISHED%2Fsrc%2Funused%2F00_createCalendar.r;h=0000000000000000000000000000000000000000;hb=62deb4244895a20a35397dfb062f0b9fe94c5012;hp=caf48ce508139a7be0b0c26963e8cd7e542adaa8;hpb=3eef8d3df59ded9a281cff51f79fe824198a7427;p=epclust.git diff --git a/old_C_code/stage2_UNFINISHED/src/unused/00_createCalendar.r b/old_C_code/stage2_UNFINISHED/src/unused/00_createCalendar.r deleted file mode 100644 index caf48ce..0000000 --- a/old_C_code/stage2_UNFINISHED/src/unused/00_createCalendar.r +++ /dev/null @@ -1,58 +0,0 @@ -## File: createCalendar.r -## Description: Create the calendar transitions to be used on KWF predictor -## Author: jc @ September 2015 - -## Function: irishCalendar -## Description: Create the calendar with day of the week and daytype. -## (It is the first step, then we need to obtain the transitions) -irishCalendar <- function(from, to){ - require(timeDate) - y0 <- as.character(substr(from, 1, 4)) - y1 <- as.character(substr(to, 1, 4)) - years <- y0:y1 - IRholidays <- c("NewYearsDay", - #saint patrick - "EasterMonday", - "GBMayDay", # may day - #june holiday - "GBSummerBankHoliday", # august holiday - #october holiday - "ChristmasDay" - #, st stephen day - ) - - - jf <- holiday(year = years, Holiday = IRholidays) - jf <- sort(unique(jf)) - dts <- timeSequence(from = paste(y0, '01', '01', sep = '-'), - to = paste(y1, '12', '31', sep = '-')) - wday <- dayOfWeek(dts) - wdayf <- unname(wday) - for(d in 1:length(wdayf)){ - if(d == 1) fpos <- 1 - if(dts[d] == jf[fpos]){ - wdayf[d] <- "Hol" - if(fpos < length(jf)) fpos <- fpos + 1 - } - } - - res <- data.frame(dow = wday, daytype = wdayf) - i0 <- which(rownames(res) == from) - i1 <- which(rownames(res) == to) - - return(res[i0:i1, ]) -} - - -# Call irishCalendar to create the calendar. -myCal <- irishCalendar(from="2011-01-01", to= "2013-12-31") -n <- nrow(myCal) - -# Obtention of the transitions -gr <- paste(myCal$daytype[1:(n - 1)], myCal$daytype[2:n], sep = '_') -gr[gr == "Hol_Hol"] <- "Sun_Hol" -myCal$gr <- c(gr, "Sat_Sun") - -# Write output to a file -# write.table(file = "calendar_ir.txt", myCal) -