Pastebin launched a little side project called VERYVIRAL.com, check it out ;-) Want more features on Pastebin? Sign Up, it's FREE!
Guest

Untitled

By: a guest on Dec 17th, 2012  |  syntax: None  |  size: 0.69 KB  |  views: 14  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. dates<-seq(as.Date("1991/1/4"),as.Date("2010/3/1"),"days")
  2.        
  3. # install.packages('timeDate')
  4. require(timeDate)
  5.  
  6. # A ’timeDate’ Sequence
  7. tS <- timeSequence(as.Date("1991/1/4"), as.Date("2010/3/1"))
  8. tS
  9.  
  10. # Subset weekdays
  11. tW <- tS[isWeekday(tS)]; tW
  12. dayOfWeek(tW)
  13.        
  14. X <- seq( as.Date("1991/1/4", format="%Y/%m/%d"), as.Date("2010/3/1", format="%Y/%m/%d"),"days")
  15. weekdays.X <- X[ ! weekdays(X) %in% c("Saturday", "Sunday") ]  
  16.         # negation easier since only two cases in exclusion
  17.         # probably do not want to print that vector to screen.
  18. str(weekdays.X)
  19.        
  20. > table(weekdays(weekdays.X) )
  21.  
  22.    Friday    Monday  Thursday   Tuesday Wednesday
  23.      1000      1000       999       999       999