How about
this:
d1 <-
timeSeq(from="1/3/2007", to="12/31/2007",
by="bizdays",
holidays=holiday.NYSE(2007))
timeDate(as.vector(sapply(as.character(d1),function(x)
sapply(c("09:00","10:00","11:00","12:00","13:00","14:00","15:00","16:00"),
function(x,y) paste(y,x,sep=" "),y=x))))
I’m
not sure if you want the 16:00 hour in or out.
Best,
Alan
Alan Hochberg
VP, Research
ProSanos Corporation
225 Market St. Ste. 502,
Harrisburg,
PA 17101
Tel 717-635-2124 * Fax
717-635-2575
From:
s-news-owner@lists.biostat.wustl.edu
[mailto:s-news-owner@lists.biostat.wustl.edu] On
Behalf Of Michael Sun
Sent: Wednesday, August 27, 2008
12:16 PM
To: s-news@wubios.wustl.edu
Subject: [S] creat hourly time
sequence without NYSE holidays, weekends
Hi,
I am wondering how to creat a hourly time sequence for the trading hours, let's
say 9am - 4pm, in a year
command line
d1 <- timeSeq(from="1/3/2007", to="12/31/2007",
by="bizdays", holidays=holiday.NYSE(2007))
gives all the trading days in 2007
I understand that timeCalendar could give hourly interval, but how could I
exclude the holidays and weekends?
e.g.
d2 <- timeCalendar(h=rep(9:16, 1), d=rep(1:31, each=8), y=2007,
format="%a %b %d, %Y %02I:%02M:%p")
this gives everyday in Jan 2007
I was also wondering can I simply use d=d1????
I use S-PLUS 8.0 for Windows.
Appreciate for any comments
Best regards,
Mc