[R] Assigning Week Numbers

Jeffrey J. Hallman jhallman at frb.gov
Wed Apr 21 16:59:31 CEST 2010


Take a look at the 'ti' stuff in the tis package on CRAN. If I
understand you correctly, you want something like this:

weekNumber <- function(aDate){
    aTi <- ti(aDate, tif = "wfriday")
    may1ymd <- 10000*year(aTi) + 501
    baseWeek <- ti(may1ymd, tif = "wfriday")
    return(aTi - baseWeek + 1)
}

-- 
Jeff



More information about the R-help mailing list