On Wed, May 21, 2008 at 04:44:32AM -0700, threshold wrote: > > Hi, I work on the date format: yyyymmdd. I would like to calculate the number > of (working or trading) days between two of such specified dates in specific > year at US stock exchange OR at least with respect to 252-days year. > > What I did so far was the conversion (example): > x<-20060213; y<-20060402 # refering to January 13 and April 2, 2006 > x1 <- as.Date(as.character(x), "%Y%m%d") > y1 <- as.Date(as.character(y), "%Y%m%d") > # nuber of calendar days > nr_cal<-diff(rbind(x1,y1))
Have a look at the fCalendar package on CRAN. Dirk -- Three out of two people have difficulties with fractions. ______________________________________________ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.