Hi R,
I have a code below that looks at the first trading day of every month.
Any help towards improving this is welcome. However my question is how
do I generalize to look at every trading day of the every month like the
last or 15th trading day of every month?
dat=read.csv("z:/ S&P-OHLC.csv")
dat[,1]=as.Date(dat[,1],"%m/%d/%Y")
dat=dat[,-(3:4)]
names(dat)[1]="Date"
yy=unique(format(dat[,1],"%Y"))
for(i in 1:
length(yy))dat[which(format(dat[,1],"%Y")==yy[i]),4]=months(dat[which(fo
rmat(dat[,1],"%Y")==yy[i]),1])
for(i in 1: (nrow(dat)-1))dat[i,5]=ifelse(dat[i,4]==dat[i+1,4],1,0)
new_dat=dat[(which(dat[,5]==0)+1),]
Thanks in advance for the help.
Ravi
This e-mail may contain confidential and/or privileged i...{{dropped:13}}
_______________________________________________
[email protected] mailing list
https://stat.ethz.ch/mailman/listinfo/r-sig-finance
-- Subscriber-posting only. If you want to post, subscribe first.
-- Also note that this is not the r-help list where general R questions should
go.