[R] Reformatting dates using chron

Andrew Criswell andy at arcriswell.com
Fri Jan 12 16:25:09 CET 2001

Hello All:

Thank you, Prof. Ripley for your suggestion. My newbiesque workaround to the problem was this:

        # Compute sequence of dates for weekdays only (exclude weekends)

           dts <- seq.dates("01/02/98", "01/10/01", by="day")
           dts <- dts[!is.weekend(dts)]

        # Reformat dates as YYYY/MM/DD

           m <- as.numeric(months(dts))
           m <- ifelse(m<10,paste(0,m,sep=""),m)

           d <- as.numeric(days(dts))
           d <- ifelse(d<10,paste(0,d,sep=""),d)

           dte <- paste(years(dts),m,d,sep="/")

There must be a more elegant and aesthetically pleasing alternative than this.

Best wishes,

Andrew Criswell
Professor of Finance
Graduate School, Bangkok University

-------------- next part --------------
An HTML attachment was scrubbed...
URL: https://stat.ethz.ch/pipermail/r-help/attachments/20010112/07f13a32/attachment.html

More information about the R-help mailing list